以下是我在服务器上发布数据的代码.
- (voID) callLoginAPI:(NSDictionary *)dictProfile{ // 1 NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:[dictProfile valueForKey:@"name"],@"username",[dictProfile valueForKey:@"first_name"],@"first_name",[dictProfile valueForKey:@"last_name"],@"last_name",[dictProfile valueForKey:@"email"],@"email",[dictProfile valueForKey:@"birthday"],@"dob",[dictProfile valueForKey:@"gender"],@"gender",[[dictProfile valueForKey:@"location"] valueForKey:@"name"],@"location",[dictProfile valueForKey:@"timezone"],@"timezone",@"",@"language",[Nsstring stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large",[dictProfile valueForKey:@"ID"]],@"profile_pic_url",@"cover_pic_url",nil]; AFhttpRequestoperationManager *manager = [AFhttpRequestoperationManager manager]; manager.requestSerializer = [AFJsONRequestSerializer serializer]; [manager POST:@"http://10.1.81.35:8000/API/login/" parameters:params success:^(AFhttpRequestoperation *operation,ID responSEObject) { NSLog(@"JsON: %@",responSEObject); } failure:^(AFhttpRequestoperation *operation,NSError *error) { NSLog(@"Error: %@",error); }];}
并作为回应我得到以下错误
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request Failed: bad request (400)" UserInfo=0x7c87b6f0 {com.alamofire.serialization.response.error.response=<NShttpURLResponse: 0x7cc220e0> { URL: http://10.1.81.35:8000/API/login/ } { status code: 400,headers { Allow = "POST,OPTIONS"; "Content-Type" = "application/Json"; Date = "Tue,07 Oct 2014 10:45:08 GMT"; Server = "WsgiServer/0.1 Python/2.7.6"; vary = "Accept,cookie"; "x-frame-options" = SAMEORIGIN;} },NSErrorFailingURLKey=http://10.1.81.35:8000/API/login/,NSLocalizedDescription=Request Failed: bad request (400),com.alamofire.serialization.response.error.data=<7b226465 7461696c 223a2022 4a534f4e 20706172 73652065 72726f72 202d204e 6f204a53 4f4e206f 626a6563 7420636f 756c6420 62652064 65636f64 6564227d>}
我无法理解为什么会出现这种错误.我的代码中缺少什么?
解决方法 错误说明了一切:你从服务器得到一个 400 response,这意味着你发送的内容要么格式不正确,要么服务器无法理解它. 总结以上是内存溢出为你收集整理的ios – 错误域= com.alamofire.error.serialization.response代码= -1011“请求失败:错误请求(400)全部内容,希望文章能够帮你解决ios – 错误域= com.alamofire.error.serialization.response代码= -1011“请求失败:错误请求(400)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)