Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

My API call works with postman but not with curl as it is not able to read a query parameter

I am consuming a REST API (POST) which is something like:

https://my.server.com/fooApp/rest/agent/<foo_id>/binaries?type=xxx&platform=LINUX

This API as you can see has 2 query parameters and also requires certain json body to be sent along with the request. The request also requires two headers – content-type and a customized authentication token header. When I run this request via Postman, it works flawlessly however when I run this with curl, my server returns an error, "Required String parameter &#39;platform&#39; is not present" (Only posted the excerpt and omitted the other common stuff)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Following is how I am trying to consume the API with curl:

curl -d @myRequestBody.json -H 'Content-Type: application/json' -H 'Session-token: MyAuthToken' https://my.server.com/fooApp/rest/agent/<foo_id>/binaries?type=xxx&platform=LINUX

What am I missing? I am calling using curl directly from my Ubuntu shell.

>Solution :

What happens if you also surround the url with apostrophes?

curl -d @myRequestBody.json -H 'Content-Type: application/json' -H 'Session-token: MyAuthToken' 'https://my.server.com/fooApp/rest/agent/<foo_id>/binaries?type=xxx&platform=LINUX'

The shell probably sees the ampersand (&) and thinks that’s the end of the command.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading