Reputation: 413
One of the requests for the tool I've been asked to update is the delete request which is structured as follows:
http://{{host_ip}}:{{port}}/lists/list_id=76218cb5fc45605cd632c26f5c5568ac/del
where the list ID will be different every time you send a request.
In order to simplify usage for end users, I want to be able to have them enter everything they need as parameters or headers in the postman GUI as they do for the other requests, rather than modifying the request URL, so I tried something like this:
http://{{host_ip}}:{{port}}/lists/list_id=:list_id/del
but if the :
is preceded by an equals sign, the postman parameters tab no longer shows list_id
as a path parameter.
Is there a way to make this work using a path parameter? Or is the best solution to explain to users that for the delete request, they need to paste the list_id
obtained from the other requests into the request URL?
Upvotes: 1
Views: 8478
Reputation: 361
Late to the party so you probably already solved it. But if anyone else is looking for something similar here is what I did. If you add just add ":id" in the URL, Postman adds a section called Path Variables underneath Query Params.
Upvotes: 7
Reputation: 19949
http://{{host_ip}}:{{port}}/lists/list_id={{list_id}}/del?list_id=1
Now users can pass the list id as query parameter.
In pre-request:
pm.environment.set("list_id",pm.request.url.getQueryString("list_id").split("=")[1])
pm.request.removeQueryParams("list_id")
this will update the list_id varaible and remove the query parameter and send the request in the format you want
Upvotes: 2
Reputation: 125
If you want to achieve what you are saying then there is no solution for your problem.
But I would suggest you change your URL. As Divyang said, your URL should be like http://{{host_ip}}:{{port}}/lists/{{list_id}}/del
or http://{{host_ip}}:{{port}}/lists/del?list_id=123
and then you can use params tab assign values to list_id.
But my best suggestion would be to use RESTful design: http://{{host_ip}}:{{port}}/lists/123123
and make a DELETE request to that URL.
Upvotes: 0