Error in Postman call

Hi folks!
I’m trying to use my first API calls using Postman.
I created a token ( in the following examples) and first I used a simple GET call to “https://api.openrouteservice.org/v2/directions/driving-car?api_key=&start=<a,b>&end=<c,d>” and in this case I obtained the correct response.
Then I’m trying to execute the POST call “https://api.openrouteservice.org/v2/directions/driving-car/gpx?coordinates=[[a,c],[c,d]]” adding the header “Authentication=”, but in this case I ever have the response:
“error”: {
“code”: 2001,
“message”: “Request body could not be read”
}…

What am I doing wrong?

Hi @agocurti,

please read the API documentation:
https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/post

The POST endpoint doesn’t support query parameters.
You can construct your request in the Playground and then generate example code for curl if you want to import an example request for Postman

Best regards

A general idea, since you’re already using Postman.
It’s possible to import our ors swagger docs directly as a simple collection or a Swagger OpenAPI 3 Collection, depending on your plan with Postman.

Just insert this link in Postman via “File → Import”: https://openrouteservice.org/wp-json/ors-api/v1/api-doc/source/V2
(simply add the link to the text field)

That directly gives you all the possible requests, well formatted and ready to be used.

After importing, just set a header called “Authorization” together with your key from Dashboard | ORS as a value to the request you want to make and click Send.

You’ll still have to provide working input data, but the API/Postman collection structure is already present and makes it maybe a bit easier with all the examples in place.

Thanks for the fast answers. I understood. Then I can do 2 things:

  1. Create a ‘curl example’ from the ORS Playground, then I can import the obtained snippet in Postman

  2. Simply I must add (because we are in ‘POST’ use) the requested parameters in Postman, but using the ‘Body’ tab, not the ‘Params’ tab, as in the following example:

In both case… it works!

Thanks again, have a nice day

2 Likes

Have a fantastic day, too, and thanks for providing us with your solution. Good to see that it works now!