我对iPhone开发很陌生,我使用AFNetworking作为我的服务库。
我查询的API是一个JSON版本,我需要发出POST请求以通过ID获取数据,这是获取新闻图像和描述的详细视图以及我使用的列表新闻获取请求并且它在那个GEt方法中工作正常我有新闻ID。为此,我尝试使用以下代码:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"News_Id": @"2",
@"News_Id": @"3",
@"News_Id": @"5"};
[manager POST:@"http://almithaq.mawaqaademo.com/AlMithaqService/API.svc/getNews_ByID" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
并在AFJSONResponseSerializer中的acceptableContentTypes中添加了@" text / html",现在出现以下错误:
2014-07-15 12:22:18.030 News[2541:60b] Error: Error Domain=NSCocoaErrorDomain Code=3840
"The operation couldn’t be completed. (Cocoa error 3840.)"
(JSON text did not start with array or object and option to allow fragments not set.)
UserInfo=0x8cf0060 {NSDebugDescription=JSON text did not start with array or object and
option to allow fragments not set., NSUnderlyingError=0x8cefcb0 "Request failed: bad
request (400)"}
答案 0 :(得分:0)
这似乎是服务器的问题。您可能想要检查是否需要任何凭据来访问数据。