2017-09-13 3 views
2

現在(2001年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

コンテンツタイプのヘッダーのように見えます。 –

答えて

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の認知キーはすべて壊れてしまったため、すべてのカテゴリで完全に再表示されました。私は数ヶ月前に鍵が壊れていたかもしれないと思ったが、おそらく昨日だったかもしれない。私は多くのテストファイルの中のどのパラメータも変更する必要はありませんでした。

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

デプロイメント時に、POST要求の問題を修正する修正があります。

関連する問題