I have a URL https://mylink/apply?data= for a server which accepts the data variable as valid JSON of following properties:-
- name: String with your name (required)
- email: String with your email address (required)
- urls: Array of strings with links
- comment: String with any comment/request you might have (optional)
My JSON file "data.json" is the following:
{
"data":
{
"name": "Rogers Bell",
"email": "[email protected]",
"urls":["https://stackoverflow.com/users/3067241/imran", "https://github.com/i4ali"],
"comment":"none"
}
}
When I use the following CURL command to send a POST request, I get error code 400 Bad Request with a message from the server Error: no data passed. indicating something wrong with my JSON format or command. Not sure what I am doing wrong here
curl -v -i -X POST -d @data.json https://mylink/apply?data= -H "Accept: application/json" -H "Content-Type: application/json" -k
I am using Windows 7 if that matters
curl, all carriage returns and newlines will be stripped out -- it would still be a valid JSON but server may not be able to recognize. Can you send the same content (with carriage returns and newlines) through Postman and check again? Is there any API document?