简体   繁体   中英

Image Bing API stopped working with Swift 2 Xcode 7

In Xcode 6 this was working:

let url = NSURL(string: "https://api.datamarket.azure.com/Bing/Search/Image?$format=json&Query='\(keywords2)'")
let request = NSMutableURLRequest(URL: url!)
request.HTTPMethod = "POST"
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")

Client received real data with image information. But in Xcode 7 I receive from Bing an error:

The authorization type you provided is not supported. Only Basic and OAuth are supported

Any idea what is going on? As you see I use Basic authentication. With external HTTP client it works, get back real data.

Tried to set up NSAppTransportSecurity like here , but did not help

-

Tried to set Info.plist , but did not help.

在此处输入图片说明

Put the following properties block inside of the main properties dictionary (under the first ).

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>www.yourwebservicedomain.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
Lazy Answer :-------------

https://www.facebook.com/1622413124641847/photos/a.1622657711284055.1073741827.1622413124641847/1655527087997117/?type=3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM