I looked at all previous answers on this subject but just can't get my POST request to work in cURL windows although it works perfectly in PostMan. I exported the code using </> and tried several combinations of export parameters... any help would greatly appreciated!
Here's my cURL code:
curl -L -X POST "https://timingserver.net/api/bridge/generic" -H "cache-control: no-cache" -H "connection: close" -H "content-type: application/json" --data-raw "{
\"username\":\"myusername\",
\"password\":\"mypassword\",
\"event\":\"demo\",
\"checkpoint\":12,
\"detections\":[{\"bib\":100, \"dt\":\"2022-01-12T13:09:23.045\"},
{\"bib\":101, \"dt\":\"2022-01-12T13:09:23.045\"},
{\"bib\":102, \"dt\":\"2022-01-12T13:09:23.045\"},
{\"bib\":199, \"dt\":\"2022-01-12T13:10:23.045\"}]
}"
Getting several errors in the same execution: Code 400, not recognized as an internal or external command... cannot find the path specified...
You need to remove the linebreaks:
curl -L -X POST "https://timingserver.net/api/bridge/generic" -H "cache-control: no-cache" -H "connection: close" -H "content-type: application/json" --data-raw "{ \"username\":\"myusername\", \"password\":\"mypassword\", \"event\":\"demo\", \"checkpoint\":12, \"detections\":[{\"bib\":100, \"dt\":\"2022-01-12T13:09:23.045\"}, {\"bib\":101, \"dt\":\"2022-01-12T13:09:23.045\"}, {\"bib\":102, \"dt\":\"2022-01-12T13:09:23.045\"}, {\"bib\":199, \"dt\":\"2022-01-12T13:10:23.045\"}] }"
To generate curl output for windows using postman click on settings next to curl code section and change line continuation character to ^ and quote double and shown in the image. This should generate output for windows. You can also change the output to single or multiline.
Related
I'm trying to create a Jelastic Manifest with a cURL command inside it. When I import it, it gives me an error but unfortunately I have no access to the console (disabled by the provider).
The command is the following :
curl -X POST <my_url> -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d "{}"
Some additionnal information :
The URL is correct 100%
The token does not contain any special characters : Only upper/lowercase characters and numbers
The command is run successfully from the command line
If I remove the first -H parameter, I can import my manifest. Same if I remove the second -H parameter and keep the first one
My guess is that, somehow, having two -H is not considered as valid but I don't know why. Any ideas ?
EDIT : A screenshot of the error shown on the platform
The "two -H parameters" wasn't a root cause in your question.
The thing is that the YAML gets the data you sent as a key/value array (dictionary).
In your example it would be:
curl -s -X POST https://test.com -H "Content-Type - as a key,
and
application/json" -H "Authorization: Bearer xx" -d "{\"Key\":\"Value\"}" - as a value.
If you need an array of strings the YAML may be as this
cmd [cp]:
- 'curl -s -X POST https://test.com -H "Content-Type: application/json" -H "Authorization: Bearer xx" -d "{\"Key\":\"Value\"}"'
If you need a multi-line string it should look like this
cmd [cp]: |
curl -s -X POST https://test.com -H "Content-Type: application/json" -H "Authorization: Bearer xx" -d "{\"Key\":\"Value\"}"
I have set up API platform and am trying to test the API using curl, eg.
curl -X POST -H "Content-Type: application/json" http://localhost/authentication_token -d '{"email":"test#test.com","password":"the_new_password"}'
curl http://localhost/docs
I am getting no response from the server, always blank.
Requests needed to be HTTPS, as it seems HTTP requests are simply thrown away / ignored. Add the -k flag since the certificate will be self signed and CURL will error out.
curl -X POST -H "Content-Type: application/json" https://localhost/authentication_token -d '{"email":"test#test.com","password":"the_new_password"}' -k
curl https://localhost/docs -k
I am trying to follow this example: http://docs.stormpath.com/rest/quickstart/
One of the steps mentions to do the following cURL request:
curl -X POST --user $YOUR_API_KEY_ID:$YOUR_API_KEY_SECRET \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name" : "My Awesome Application"
}' \
'https://api.stormpath.com/v1/applications?createDirectory=true'
I am using online cURL from : http://onlinecurl.com/
Here is the snapshot of the curl request:
Here is the snapshot of the Header Response:
Can anybody please tell me what is wrong?
I'm also having problems with that tool. I tried what you show in your screenshot, plus some other combinations. I actually get a different error (media type unauthorized). I suspect this tool uses some kind of proxy that is messing with the request.
when i post a raw string as an input to JSON REST Service call it is executing ex:
curl -d "{\"input1\": \"as\", \"input2\": \"ad\"}" -i -X POST -H "Content-Type:application/json" http://localhost/rtygies/Service1.svc/rest/receivedata1
But when i am posting as an xml as input it is giveng error as below:
curl -d "{\"input1\": \"<xml></xml>\", \"input2\": \"<xml></xml>\"}" -i -X POST -H "Content-Type:application/json" http://localhost/rtygies/Service1.svc/rest/receivedata1
Error: < was unexpected at this time
I am using curl in windows.
can any one say how to post xml as a string input to Rest service in JSON format from curl
Actually, I don't know what is the case,
but I got an error said < is unexpected this time
when I tried the following command (on windows):
curl -u admin:password -XPOST -H 'Content-type: text/xml' -d '<namespace><prefix>newWorkspace</prefix><uri>http://geoserver.org</uri></namespace>' http://localhost:8080/geoserver/rest/namespaces
Then I changed the single quote into double quotes and it worked.
Redirection symbols can be escaped by "
Try using
curl -d "{\"input1\": \""<xml></xml>"\", \"input2\": \""<xml></xml>"\"}" -i -X POST -H "Content-Type:application/json" http://localhost/rtygies/Service1.svc/rest/receivedata1
I had no luck with double-quotes, however escaping < and > with ^ worked for me.
So your curl becomes..
curl -d "{\"input1\": \"^<xml^>^</xml^>\", \"input2\": \"^<xml^>^</xml^>\"}" -i -X POST -H "Content-Type:application/json" http://localhost/rtygies/Service1.svc/rest/receivedata1
According to the StarGate documentation, this is how a CURL command should look like:
% curl -H "Content-Type: text/xml" --data '[...]' http://localhost:8000/test/testrow/test:testcolumn
This is what I'm trying:
% curl -X POST -H "Accept: text/xml" --data '[<CellSet><Row key="cm93MQ=="><Cell column="dGl0bGU6YQ==">d29ya2Vk</Cell></Row></CellSet>]' http://localhost:8080/test/row1/title
Keep getting HTTP 415, Unsupported Media Type.. any ideas what I'm missing there?
Your current curl options specify you'd like XML output, and curl is assuming you are posting url-encoded form data (and specifying the wrong Content-Type in the HTTP headers).
Amend your -H "Accept: text/xml" to -H "Content-Type: text/xml" and you should be good