我有以下POST请求:
curl --request POST \
--url http://<myurl> \
--header 'content-type: application/json; charset=UTF-8' \
--data '{
"message": "Hebräisch?"
}'
我必须选择UTF-8字符集以正确的方式对消息进行编码,例如'hebräisch‘。
我发现有几个帖子问了同样的问题,似乎在内容类型中添加了字符集,解决了他们的问题,但我从服务器得到了以下错误:
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>
以及如何解决这个问题的建议?
发布于 2019-05-22 21:16:34
您的请求中没有任何问题。它在客户端运行得很好。这取决于你发布的服务器如何处理它。我尝试了一下Postman Echo服务,它看起来完全没问题:
curl --request POST --url https://postman-echo.com/post --header 'content-type: application/json; charset=UTF-8' --data '{ "message": "Hebräisch?" }' | jq
请参阅Postman echo测试工具。
注意:我使用jq
漂亮地打印服务器输出,如果没有就跳过它)
https://stackoverflow.com/questions/56239748
复制相似问题