Created
May 8, 2020 07:21
-
-
Save UgmaDevelopment/abfea553b77312d156111769bf2c05ab to your computer and use it in GitHub Desktop.
An error that happens when you try to use double quotes in the JSON that you send with cURL. The solution: https://stackoverflow.com/a/22597714/5432315
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\Users\Turek>curl -v -X POST localhost:8080/employees -H 'Content-Type:application/json' -d '{"name": "Samwise Gamgee", "role": "gardener"}' | python -mjson.tool | |
Note: Unnecessary use of -X or --request, POST is already inferred. | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1... | |
* TCP_NODELAY set | |
* Connected to localhost (::1) port 8080 (#0) | |
> POST /employees HTTP/1.1 | |
> Host: localhost:8080 | |
> User-Agent: curl/7.55.1 | |
> Accept: */* | |
> 'Content-Type:application/json' | |
> Content-Length: 7 | |
> Content-Type: application/x-www-form-urlencoded | |
> | |
} [7 bytes data] | |
100 7 0 0 100 7 0 7 0:00:01 --:--:-- 0:00:01 148* upload completely sent off: 7 out of 7 bytes | |
< HTTP/1.1 415 | |
< Content-Type: application/json | |
< Transfer-Encoding: chunked | |
< Date: Fri, 08 May 2020 07:20:13 GMT | |
< | |
{ [205 bytes data] | |
100 206 0 199 100 7 199 7 0:00:01 --:--:-- 0:00:01 628 | |
* Connection #0 to host localhost left intact | |
Note: Unnecessary use of -X or --request, POST is already inferred. | |
* Rebuilt URL to: Samwise Gamgee,/ | |
* Could not resolve host: Samwise Gamgee, | |
* Closing connection 1 | |
curl: (6) Could not resolve host: Samwise Gamgee, | |
Note: Unnecessary use of -X or --request, POST is already inferred. | |
* Rebuilt URL to: role:/ | |
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0* Could not resolve host: role | |
* Closing connection 2 | |
curl: (6) Could not resolve host: role | |
curl: (3) [globbing] unmatched close brace/bracket in column 9 | |
{ | |
"timestamp": "2020-05-08T07:20:13.315+0000", | |
"status": 415, | |
"error": "Unsupported Media Type", | |
"message": "Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported", | |
"path": "/employees" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment