2017-03-31 2 views
0

빙 뉴스 검색 API에 대한 몇 가지 문제가 있습니다. 가장 이상한 것은 카테고리별로 검색하는 것입니다. 설명서에 따르면 카테고리는 문자열이어야하며 여러 리소스가 있습니다. 어떤 값을 받아들이므로 나는 콘솔 (https://dev.cognitive.microsoft.com/docs/services/56b43f72cf5ff8098cef380a/operations/56b449fbcf5ff81038d15cdf/console)과 함께 가기로 결심했다. 카테고리를 선택하고 키를 입력하면 올바르게 작동합니다.빙 뉴스 검색 API에 400 오류가 발생했습니다.

{ 
    "_type": "ErrorResponse", 
    "errors": [ 
    { 
     "code": "RequestParameterInvalidValue", 
     "message": "Parameter has invalid value.The category parameter is invalid.", 
     "parameter": "category", 
     "value": "Entertainment" 
    } 
    ] 
} 

어떤 생각이 내가 무슨 일을하고 있어요 : 문제는 내가 우체부로 콘솔에서 동일한 URL을 복사 할 때, 나는 동일한 키를 사용하고 난이 몸 "400 잘못된 요청"헤더를 얻을 수있다 이리?

답변

0

여기 아주 해키 해결 방법입니다 : 요청이 개발자 콘솔을 통해 잘 작동하기 때문에 , 난, 잘 작동하는 것 같다 요청을 검사하고 컬을 생각 repeate하려고 명령은 다음과 같다 :

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":""}' 
"호스트", "GET": "api.cognitive.microsoft.com을" "계획"나는 보내고있다

JSON 데이터는이이

{ "httpMethod"(위의 명령에서 복사)입니다 : "https", "path": "bing/v5.0/news /? Category = Entertainment", "헤더": [{ "이름": "호스트", "값": "api.cognitive.microsoft.com", "inputTypeValue": "텍스트", "공개": false, "옵션": null"Ocp-Apim-Subscription-Key", "값": "", "inputTypeValue": "필수": true, true ","readonly ": false,"custom ": true,"secret ": true]],"parameters ": [{"password " "options": [ "비즈니스", "엔터테인먼트", "건강", "건강", " 정치 ", "ScienceAndTechnology ","Sports ","US/UK ","World "],"custom ": fal se ","description ":"

발신자가 원하는 뉴스 기사 의 범주를 지정합니다.

\ n을 ","유형 이름 ":"문자열 "}], "몸 ":"내가 다른 해결책을 찾을 수 없기 때문에 지금은이 같은 올바른 표시됩니다

"}

관련 문제