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 'platform' is not present" (Only posted the excerpt and omitted the other common stuff)
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.
CodePudding user response:
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.