总而言之,我正在尝试使用AFNetworking
类AFHTTPRequestOperationManager
在.net(asmx)API上发送帖子请求,这是我的代码,请求,
-(void) request {
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *params = @{@"test1": @"123",
@"test2": @"345"};
// manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/xml"];
[manager POST:@"http://somewebsite.com/getdetail.asmx/AllDetails" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
NSLog(@"%@",operation.description);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
NSLog(@"%@",operation.responseString);
}];
}
我收到以下响应字符串
{ “结果”:[], “状态”: “SUCCESS”}
它会输出以下错误,
错误:错误域= NSCocoaErrorDomain代码= 3840“操作无法完成。(Cocoa错误3840.)”(JSON文本没有以数组或对象开头,并且选项允许未设置片段。)UserInfo = 0x996a630 {NSDebugDescription = JSON文本不以数组或对象开头,并且选项允许未设置片段。}
出了什么问题?
如何使用AFNetworking将帖子请求发送到.net asmx API,这是正确的方法吗?