Delimiting a path variable (or path parameter) when it's a part of the file name

I am testing Discourse API. To retrieve a single post, the syntax is GET /posts/{id}.json.

The post id, obviously, is a good candidate for a path variable. However, if I write in the URL bar {{host}}/posts/:id.json, Postman considers the path variable name is id.json rather than just id. Is there a way to delimit the path variable definition so that it replaces just the “id”?

The docs on variables does not specify any closing delimiter, it seems that the path parameter name ends at slash or at line end.

That’s not really a path, but a filename.

Therefore I would have thought it should be…

{{host}}/posts/{{id}}.json

just store the ID as a collection or environment variable, and your good to go.

Yeah, that’s a valid workaround, but it would be nicer to have that value tied to the request, and visible/accessible in the request’s UI.
I am now using {{host}}/posts/:id, and populating this id path variable with 1234.json. Not ideal, but ok.

I think you hit the nail on the head in your initial post.

Postman is expecting a path element to end with / or a space.

I’d have to look up the URL standard but in my mind if something ends with .extension, then its a filename rather than a path, so sounds like Postman is interpreting it correctly.

Sounds like you have two workarounds, so all good.

1 Like