我试图在我的本地服务器上调用api.PHP(使用MAMP).
正在调用服务器端api.PHP,但PHP代码中的_POST内容包含以下错误:
原文链接:https://www.f2er.com/php/130677.html正在调用服务器端api.PHP,但PHP代码中的_POST内容包含以下错误:
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 = 0x15d7bdd0 {NSDebugDescription = JSON text did not start with array or object and option to allow fragments not set.}
我的应用程序试图将JSON POST请求发送到api.PHP是一个使用AFNetworking 2的iOS应用程序
这是我的请求代码:
- (void)postUpdateRequest { if (!dataModel) dataModel = [[DataModel alloc] init]; NSDictionary *params = @{@"foo": @"bar2"}; NSLog(@"%@",params); /* NSDictionary *params = @{@"cmd":@"update",@"user_id":[dataModel userId],@"token":[dataModel deviceToken] };//@"ip_address":[dataModel getIPAddress]};*/ AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; // manager.requestSerializer = [AFJSONRequestSerializer serializer]; [manager POST:ServerApiURL parameters:params success:^(AFHTTPRequestOperation *operation,id responSEObject) { NSLog(@"JSON: %@",responSEObject); } failure:^(AFHTTPRequestOperation *operation,NSError *error) { NSLog(@"Error: %@",error); }]; }
我查看了整个互联网,但无法找到我的具体问题的答案.
无论我做什么,我都会得到同样的错误.
为什么我的JSON格式不正确?我似乎也找不到嗅探我实际发送的JSON的方法.
谢谢.