curl: (6) Could not resolve host: application

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

Getting url: (6) Could not resolve host: application error after this command :

curl -i -H 'Content-Type: application/json' -d '{"Code":"FR","Name":"France"}' http://127.0.0.1:8080/countries 

Full error log:

curl: (6) Could not resolve host: application HTTP/1.1 415 Unsupported Media Type Content-Type: application/json; charset=utf-8 X-Powered-By: go-json-rest Date: Sat, 02 Apr 2016 05:31:20 GMT Content-Length: 73  { "Error": "Bad Content-Type or charset, expected 'application/json'" } 

What's wrong with this command?

Edit:

I solved my problem editing like this in windows : "{/"Code/":/"FR/"}"

回答1:

In my case, putting space after colon was wrong.

# Not work curl -H Content-Type: application/json ~ # OK curl -H Content-Type:application/json ~ 


回答2:

It's treating the string application as your URL.
This means your shell isn't parsing the command correctly.
My guess is that you copied the string from somewhere, and that when you pasted it, you got some characters that looked like regular quotes, but weren't.
Try retyping the command; you'll only get valid characters from your keyboard. I bet you'll get a much different result from what looks like the same query. As this is probably a shell problem and not a 'curl' problem (you didn't build cURL yourself from source, did you?), it might be good to mention whether you're on Linux/Windows/etc.



回答3:

Example for Slack.... (use your own web address you generate there)...

curl -X POST -H "Content-type:application/json" --data "{\"text\":\"A New Program Has Just Been Posted!!!\"}" https://hooks.slack.com/services/T7M0PFD42/BAA6NK48Y/123123123123123



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!