错误域= com.alamofire.error.serialization.response代码=

编程入门 行业动态 更新时间:2024-10-26 12:31:10
本文介绍了错误域= com.alamofire.error.serialization.response代码= -1011“请求失败:错误请求(400)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用AFnetworking库在服务器上发布数据。

I am using AFnetworking library to post data on server.

以下是我在服务器上发布数据的代码。

Following is my code to post data on server.

- (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:@"graph.facebook/%@/picture?type=large",[dictProfile valueForKey:@"id"]],@"profile_pic_url", @"",@"cover_pic_url",nil]; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; [manager POST:@"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); }]; }

作为回应我收到以下错误

and in response I got following 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: 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=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>}

我不能理解为什么我会遇到这种错误。我的代码中缺少什么?

I am not able to understand why I got the such kind of error. What is missing in my code?

推荐答案

错误说明了一切:你有一个400响应,意味着您发送的内容未正确格式化,或服务器无法理解。

The error says it all: you got a 400 response from the server, meaning that what you sent was either not formatted properly, or the server just couldn't understand it.

更多推荐

错误域= com.alamofire.error.serialization.response代码=

本文发布于:2023-11-26 05:44:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   代码   alamofire   error   serialization

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!