I want to post the following JSON:
{
"cities": {
"chicago": 123,
"boston": 245
}
}
Using curl as x-www-form-urlencoded without using a .json file. I cannot figure out how to build the curl -F ...
I want to post the following JSON:
{
"cities": {
"chicago": 123,
"boston": 245
}
}
Using curl as x-www-form-urlencoded without using a .json file. I cannot figure out how to build the curl -F ...
For application/x-www-form-urlencoded you could try:
curl -d "param1=value1¶m2=value2" -X POST http://localhost:3000/blahblah
Where param1=value... have to be your JSON data as chicago=123&boston=245
Or explicit form:
curl -d "param1=value1¶m2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:3000/blahblah
Instead of http://localhost:3000/blahblah you should provide real URL of your service.
The whole point of curl -F, according to the man page, is "to POST data using the Content-Type multipart/form-data according to RFC 2388." In other words, it's best used when you need to emulate an HTML form with a file input.
Instead use curl -d to specify the raw POST data:
curl -d '{"cities":{"chicago":123,"boston":245}}' https://example.com
If this is actually how they expect data, it is a misconfigured server, as x-www-form-urlencoded data should be in the form key=value.