这是一个非常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", "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": "", "inputTypeValue": "password", "revealed" :假,“选项”:[],“必需”:真,"readonly": false, "custom": true, "secret": true }], "parameters": [{ "name": "Category", "value": "Entertainment", "inputType": "text", “必填”:false,“选项”:[“商业”、“娱乐”、“健康”、“政治”、“科学与技术”、“体育”、“美国/英国”、“世界”]、“自定义”:错误,“描述”:“"inputType": "text", "required": false, "options": ["Business", "Entertainment", "Health", "Politics", "ScienceAndTechnology", "Sports", "US/UK", "世界"], "自定义": false, "描述": ""inputType": "text", "required": false, "options": ["Business", "Entertainment", "Health", "Politics", "ScienceAndTechnology", "Sports", "US/UK", "世界"], "自定义": false, "描述": "
指定调用者希望返回的新闻文章类别。
\n", "typeName": "string" }], "body": "" }
我暂时将其标记为正确,因为我找不到任何其他解决方案