执行curl POST请求报错无法识别URL、Port number ended with '['及MissingRequiredBody求助
问题原因
你编写的curl命令存在参数误用问题:--request(与-X功能完全等价)的参数值只能是HTTP请求方法(如POST、GET等),你错误地将请求URL放在了--request之后,同时重复定义了请求方法,导致curl将后续的请求体内容识别为URL的一部分进行解析,才会出现端口解析报错、请求体被识别为接口路径、提示缺少请求体的问题。
修正后的命令
curl.exe -X POST "http://localhost:5000/text/analytics/v3.0-preview/sentiment" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"documents\":[{\"language\":\"en\",\"id\":\"1-en\",\"text\":\"Hello world. This is some input text that I love.\"}]}" -g
如果需要显式使用--request参数,写法如下:
curl.exe --request POST "http://localhost:5000/text/analytics/v3.0-preview/sentiment" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"documents\":[{\"language\":\"en\",\"id\":\"1-en\",\"text\":\"Hello world. This is some input text that I love.\"}]}" -g
内容的提问来源于stack exchange,提问作者grisha
相关产品推荐
相关产品推荐

