这是一个非常Hacky的解决方法:
由于请求通过开发者控制台正常工作,我检查了请求并尝试重复它认为 curl 似乎工作正常,命令如下:
curl 'https://dev.cognitive.microsoft.com/console/query' -H 'Content-Type: application/json' --data-binary '{"httpMethod":"GET","host":"api.cognitive.microsoft.com","scheme":"https","path":"bing/v5.0/news/?Category=Entertainment","headers":[{"name":"Host","value":"api.cognitive.microsoft.com","inputTypeValue":"text","revealed":false,"options":null,"required":true,"readonly":true,"custom":false},{"name":"Ocp-Apim-Subscription-Key","value":"<your key value>","inputTypeValue":"password","revealed":false,"options":[],"required":true,"readonly":false,"custom":true,"secret":true}],"parameters":[{"name":"Category","value":"Entertainment","inputType":"text","required":false,"options":["Business","Entertainment","Health","Politics","ScienceAndTechnology","Sports","US/UK","World"],"custom":false,"description":"<p>Specifies which category of news articles the caller wants returned.</p>\n","typeName":"string"}],"body":""}'
我发送的 json 数据是这样的(从上面的命令中复制的)
{ "httpMethod": "GET", "host": "api.cognitive.microsoft.com",
“方案”:“https”,“路径”:“bing/v5.0/news/?Category=Entertainment”,
“标题”:[{“名称”:“主机”,“值”:
“api.cognitive.microsoft.com”,“inputTypeValue”:“文本”,
“显示”:假,“选项”:空,“必需”:真,
“只读”:真,“自定义”:假},{“名称”:
"Ocp-Apim-Subscription-Key", "值": "",
“inputTypeValue”:“密码”,“显示”:假,“选项”:[],
“必需”:真,“只读”:假,“自定义”:真,“秘密”:
true }], "参数": [{ "name": "Category", "value":
“娱乐”,“inputType”:“文本”,“必需”:false,
“选项”:[“商业”,“娱乐”,“健康”,“政治”,
“ScienceAndTechnology”、“Sports”、“US/UK”、“World”]、“custom”:
假,“描述”:“
指定新闻文章的类别
调用者想要返回。
\n", "typeName": "string" }],
“身体”: ”” }
我暂时将其标记为正确,因为我找不到任何其他解决方案