Importing Postman files with /api/*** endpoints not working

I have a Postman collection that I have exported as a .json file and store in my team’s GitLab repo. We recently updated our endpoints to have /api prefixing them, so I edited the .json file to reflect those changes. I then imported the .json file into Postman, but the /api changes did not reflect in Postman. For example, this is one of the endpoints:

"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{API_BASE_URL}}/api/payroll/actuals?",
							"host": [
								"{{API_BASE_URL}}"
							],
						}
					},
					"response": []
				},

Any idea why this is not importing my endpoints correctly?
Screenshot 2024-07-18 at 10.51.51 AM

Hey @aviation-explorer-21 :wave:

Are you able to share a scaled down version of your edited Collection file?

You can also try and manually create the correct request in Postman and export that. That can be used to do a 1:1 comparison with your changes and what the changes should look like?

I just changed the endpoint manually in Postman and exported the collection and I can see that the request is identical

{
	"info": {
		"_postman_id": "***",
		"name": "SPM API",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "Payroll",
			"item": [
				{
					"name": "Actuals-Workday",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"No errors are returned\", function () {",
									"    var json = pm.response.json();",
									"    pm.expect(json).to.not.ownProperty(\"errors\");",
									"});",
									"",
									"var payrollData = pm.response.json();",
									"",
									"pm.test(\"There was data returned\", function () {",
									"    pm.expect(payrollData).length.to.greaterThan(0)",
									"});",
									""
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [],
						"url": {
							"raw": "{{API_BASE_URL}}/api/payroll/actuals",
							"host": [
								"{{API_BASE_URL}}"
							],
							"path": [
								"payroll",
								"actuals"
							]
						}
					},
					"response": []
				}
			]
		}
	]
}

Above is a small part of the collection. I have almost 20 endpoints (which is why I just wanted to edit the json file), but I shared just one. This code above when I import into Postman does not the /api reflected.

Oh I see it must be part of the “path”, not sure why there are two places that controller the URL of the endpoint.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.