Ios 请求失败:内部服务器错误(500)和Cocoa错误3840,字符0周围的值无效

Ios 请求失败:内部服务器错误(500)和Cocoa错误3840,字符0周围的值无效,ios,objective-c,cocoa,afnetworking,afnetworking-2,Ios,Objective C,Cocoa,Afnetworking,Afnetworking 2,它似乎在web中工作: Web响应标题: Connection:keep-alive Content-Length:394 Content-Type:application/json Date:Sun, 22 Mar 2015 18:36:06 GMT Server:nginx/1.6.2 Vary:Accept-Encoding X-Powered-By:Express Web请求头: Accept:application/json,

它似乎在web中工作:

Web响应标题:

    Connection:keep-alive
    Content-Length:394
    Content-Type:application/json
    Date:Sun, 22 Mar 2015 18:36:06 GMT
    Server:nginx/1.6.2
    Vary:Accept-Encoding
    X-Powered-By:Express
Web请求头:

Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1NDVjYzNjYzQ2N2I3YjAyMDBhMWNkOWEiLCJpYXQiOjE0MjcwNDM3Mzk1NjQsImV4cCI6MTQ5MDExNTczOTU2NH0.Xqm-b12QWcEa6MPXyKa1E8m88hGZI9KfJl7Img3mACU
Connection:keep-alive
Content-Length:225
Content-Type:application/json;charset=UTF-8
Web请求有效负载:

{"id":"550f15122cc2708c2d9c65b8","users":["xiruken@gmail.com"],"welcomeMessage":"Hi there. We’ll be using Next24 to keep track of our daily high priority items as a group during this project.","newUser":"xiruken@gmail.com"}
但是在我的原生iOS项目中没有使用objective-C

相同参数:

NSDictionary查询:

AFN网络代码:

使用AFJSONResponseSerializer时出现以下错误:

2015-03-23 03:28:26.773 Next25[5801:302572] Failed! Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0x7fdbb252a6e0 {NSDebugDescription=Invalid value around character 0., NSUnderlyingError=0x7fdbb252c410 "Request failed: internal server error (500)"}
我甚至允许片段,甚至设置了可接受的内容类型

将其更改为AFHTTPResponseSerializer会给我一个不同的错误:

2015-03-23 03:30:30.797 Next25[5852:303849] Failed! Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo=0x7fb129e4e930 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fb129e36320> { URL: https://myproject.com/api/projects/550f15122cc2708c2d9c65b8/invite_users } { status code: 500, headers {
    Connection = "keep-alive";
    "Content-Length" = 21;
    "Content-Type" = "text/html";
    Date = "Sun, 22 Mar 2015 19:26:56 GMT";
    Server = "nginx/1.6.2";
    Vary = "Accept-Encoding";
    "X-Powered-By" = Express;
} }, NSErrorFailingURLKey=https://myproject.com/api/projects/550f15122cc2708c2d9c65b8/invite_users, com.alamofire.serialization.response.error.data=<496e7465 726e616c 20536572 76657220 4572726f 72>, NSLocalizedDescription=Request failed: internal server error (500)}

您是否尝试使用Charles来验证请求?它看起来更像是一个请求问题导致了服务器问题和错误响应。我请关闭此线程。我终于找到了答案。我忘了添加这个self.sessionManager.requestSerializer=[AFJSONRequestSerializer];您需要删除该问题-
2015-03-23 03:28:26.773 Next25[5801:302572] Failed! Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0x7fdbb252a6e0 {NSDebugDescription=Invalid value around character 0., NSUnderlyingError=0x7fdbb252c410 "Request failed: internal server error (500)"}
2015-03-23 03:30:30.797 Next25[5852:303849] Failed! Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo=0x7fb129e4e930 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fb129e36320> { URL: https://myproject.com/api/projects/550f15122cc2708c2d9c65b8/invite_users } { status code: 500, headers {
    Connection = "keep-alive";
    "Content-Length" = 21;
    "Content-Type" = "text/html";
    Date = "Sun, 22 Mar 2015 19:26:56 GMT";
    Server = "nginx/1.6.2";
    Vary = "Accept-Encoding";
    "X-Powered-By" = Express;
} }, NSErrorFailingURLKey=https://myproject.com/api/projects/550f15122cc2708c2d9c65b8/invite_users, com.alamofire.serialization.response.error.data=<496e7465 726e616c 20536572 76657220 4572726f 72>, NSLocalizedDescription=Request failed: internal server error (500)}