我收到JSON字符串中不良區AFNetworking預期的內容類型錯誤
NSURL *url = [[NSURL alloc] initWithString:@"http://www.vinipost.com/Services/Update/UpdateService.asmx/GetPropSubType?"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"%@", JSON);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
}];
[operation start];
輸出:
Request Failed with Error: Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
"text/json",
"text/javascript",
"application/json",
"text/html"
)}, got text/plain" UserInfo=0x71521a0 {NSLocalizedRecoverySuggestion=[{"PropTypId":1,"PropCatId":1,"PropTyp":"Flat/ Condo"}.......**
@ LombaX-行,所以如何處理它 –
將UpdateService.asmx網頁的代碼更改爲使用文本/純文本內容類型返回正確的JSON響應。我不能幫你用ASP – LombaX
@ lombaX-感謝,錯誤已經從服務器端修正.. –