2017-09-13 4 views
2

현재 (2017 년 9 월 13 일) Bing Image Search v 5.0에서 백엔드 API를 변경 했습니까?Bing Image Search v5.0에서 오류를 반환합니다.

this console을 사용하면 "multipart/form-data"값이있는 헤더 "Content-Type"을 추가하면 예상 값으로 응답합니다. 동일한 매개 변수와 헤더 내 iOS 앱에서 호출 할 때

그러나, 나는의 에러 응답을받을 "RequestParameterInvalidValue을, 메시지 ="파라미터가 유효하지 않은 값입니다. "; 매개 변수 = imgUrl에를;"

NSString* path = @"https://api.cognitive.microsoft.com/bing/v5.0/images/search"; 
    NSString* skip = [NSString stringWithFormat:@"skip=%li", (long)searchOffset]; 
    NSString* queryString = [NSString stringWithFormat:@"q=%@", searchQuery]; 
    NSArray* array = @[ 
        // Request parameters 
        @"entities=true", 
        @"count=50", 
        skip, 
        @"safeSearch=Strict", 
        queryString 

        ]; 

NSString* string = [array componentsJoinedByString:@"&"]; 
path = [path stringByAppendingFormat:@"?%@", string]; 

NSLog(@"%@", path); 

NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]]; 
[_request setHTTPMethod:@"POST"]; 
// Request headers 
[_request setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"]; 
[_request setValue:accessKey forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"]; 
// Request body 
[_request setHTTPBody:[path dataUsingEncoding:NSUTF8StringEncoding]]; 

내가 테스트의 코드에서 Content-Type 헤더를 제거하고 작업 응답을받을 수 있지만, 이것은 우리의 생산 응용 프로그램에 어제 일 :

다음 코드는 어제의로 일했다. 승인을 위해 앱을 다시 제출하지 않고도 프로덕션 코드를 다시 사용할 수있는 해결 방법이 있습니까?

+0

나는 어제 같은 행동을 실제로 경험했다! 내 테스트가 통과되었고 갑자기이 오류가 정확히 같은 오류로 실패하기 시작했습니다 ... –

+0

이제 content-type 헤더가 더 이상 사용되지 않습니다. –

답변

0

이 오류가 발생했습니다. 그것을 디버깅하려고이 내 덤프 반환 것입니다 :

HTTP_Request2_Response {#460 ▼ 
#version: "1.1" 
#code: 400 
#reasonPhrase: "Bad Request" 
#effectiveUrl: 
"https://api.cognitive.microsoft.com/bing/v5.0/images/search?q=cats" 
#headers: array:16 [▼ 
"cache-control" => "no-cache, no-store, must-revalidate" 
"pragma" => "no-cache" 
"content-length" => "169" 
"content-type" => "application/json; charset=utf-8" 
"expires" => "-1" 
"vary" => "Accept-Encoding" 
"server" => "Microsoft-HTTPAPI/2.0" 
"p3p" => "CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"" 
"bingapis-traceid" => "18AAD6F029D1439EB653971FBD07B6EF" 
"x-msedge-clientid" => "260206484A6764FE375C0CB54B826518" 
"x-msapi-userstate" => "d3dd" 
"x-msedge-ref" => "Ref A: 18AAD6F029D1439EB653971FBD07B6EF Ref B: 
SG2EDGE0713 Ref C: 2017-09-14T07:12:07Z" 
"apim-request-id" => "9de68803-fee7-4a56-aa0e-f00e2b43929b" 
"strict-transport-security" => "max-age=31536000; includeSubDomains; 
preload" 
"x-content-type-options" => "nosniff" 
"date" => "Thu, 14 Sep 2017 07:12:06 GMT" 
] 
#cookies: [] 
#lastHeader: "date" 
#body: "{"_type": "ErrorResponse", "instrumentation": {}, "errors": 
[{"code": "RequestParameterInvalidValue", "message": "Parameter has 
invalid value.", "parameter": "i ▶" 
#bodyEncoded: true 

나는 내 코드에 문제가있는라고 생각하지만 나는 여기에 스레드를보고는 빙/푸른의 끝에 오류라고 결론을 내렸다.

0

다음은 curl입니다. 그러나 어제 Microsoft 코드 키가 깨 졌으므로 모든 범주에서 Microsoft인지 키를 완전히 다시 읽습니다. 나는 아마도 몇 달 전에 열쇠가 깨 졌다고 생각했지만 아마도 어제 일 수도 있습니다. 내 많은 테스트 파일에서 매개 변수를 변경할 필요가 없었습니다.

curl "https://api.cognitive.microsoft.com/bing/v5.0/images/search?q=cats" -H "Content-Type: multipart/form-data" -H "Ocp-Apim-Subscription-Key: <My Bing Search API Key 1>" 
0

게시 요청에 대한 문제를 해결해야하는 배포판의 수정 사항이 있습니다.