我使用2.0版的AFNetworking , 如下方法向服务端请求数据

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

manager.requestSerializer  = [AFJSONRequestSerializer serializer];  

manager.responseSerializer = [AFHTTPResponseSerializer serializer]; 

[manager POST:mylink parameters:@{@"signals" : ibString} success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject){} failure:^(AFHTTPRequestOperation *_Nonnull operation, NSError * _Nonnull error) {}];

打印返回如下错误:

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: not found (404)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x153f55640> { URL: mylink } { status code: 404, headers {

    Connection = "keep-alive";

    "Content-Encoding" = gzip;

    "Content-Language" = en;

    "Content-Type" = "text/html;charset=utf-8";

    Date = "Mon, 13 Jun 2016 12:09:04 GMT";

    "Transfer-Encoding" = Identity;

    Vary = "Accept-Encoding";

} }, NSErrorFailingURLKey=mylink, com.alamofire.serialization.response.error.data=<3c68746d 6c3e3c68 6561643e 3c746974 6c653e41 70616368 6520546f 6d636174 2f372e30 2e363520 2d204572 726f7220 7265706f 72743c2f 7469746c 653e3c73 74796c65 3e3c212d 2d483120 7b666f6e 742d6661 6d696c79 3a546168 6f6d612c 41726961 6c2c7361 6e732d73 65726966 3b636f6c 6f723a77 68697465 3b626163 6b67726f 756e642d 636f6c6f 723a2335 32354437 363b666f 6e742d73 697a653a 32327078 3b7d2048 32207b66 6f6e742d 66616d69 6c793a54 61686f6d 612c4172 69616c2c 73616e73 2d736572 69663b63 6f6c6f72 3a776869 74653b62 61636b67 726f756e 642d636f 6c6f723a 23353235 4437363b 666f6e74 2d73697a 653a3136 70783b7d 20483320 7b666f6e 742d6661 6d696c79 3a546168 6f6d612c 41726961 6c2c7361 6e732d73 65726966 3b636f6c 6f723a77 68697465 3b626163 6b67726f 756e642d 636f6c6f 723a2335 32354437 363b666f 6e742d73 697a653a 31347078 3b7d2042 4f445920 7b666f6e 742d6661 6d696c79 3a546168 6f6d612c 41726961 6c2c7361 6e732d73 65726966 3b636f6c 6f723a62 6c61636b 3b626163 6b67726f 756e642d 636f6c6f 723a7768 6974653b 7d204220 7b666f6e 742d6661 6d696c79 3a546168 6f6d612c 41726961 6c2c7361 6e732d73 65726966 3b636f6c 6f723a77 68697465 3b626163 6b67726f 756e642d 636f6c6f 723a2335 32354437 363b7d20 50207b66 6f6e742d 66616d69 6c793a54 61686f6d 612c4172 69616c2c 73616e73 2d736572 69663b62 61636b67 726f756e 643a7768 6974653b 636f6c6f 723a626c 61636b3b 666f6e74 2d73697a 653a3132 70783b7d 41207b63 6f6c6f72 203a2062 6c61636b 3b7d412e 6e616d65 207b636f 6c6f7220 3a20626c 61636b3b 7d485220 7b636f6c 6f72203a 20233532 35443736 3b7d2d2d 3e3c2f73 74796c65 3e203c2f 68656164 3e3c626f 64793e3c 68313e48 54545020 53746174 75732034 3034202d 202f6a2d 70617061 6b616b61 2d776562 2f696e64 6f6f726c 6f632f6c 6f634275 696c6469 6e674279 49426561 636f6e2e 70706b6b 3c2f6831 3e3c4852 2073697a 653d2231 22206e6f 73686164 653d226e 6f736861 6465223e 3c703e3c 623e7479 70653c2f 623e2053 74617475 73207265 706f7274 3c2f703e 3c703e3c 623e6d65 73736167 653c2f62 3e203c75 3e2f6a2d 70617061 6b616b61 2d776562 2f696e64 6f6f726c 6f632f6c 6f634275 696c6469 6e674279 49426561 636f6e2e 70706b6b 3c2f753e 3c2f703e 3c703e3c 623e6465 73637269 7074696f 6e3c2f62 3e203c75 3e546865 20726571 75657374 65642072 65736f75 72636520 6973206e 6f742061 7661696c 61626c65 2e3c2f75 3e3c2f70 3e3c4852 2073697a 653d2231 22206e6f 73686164 653d226e 6f736861 6465223e 3c68333e 41706163 68652054 6f6d6361 742f372e 302e3635 3c2f6833 3e3c2f62 6f64793e 3c2f6874 6d6c3e>, NSLocalizedDescription=Request failed: not found (404)}, operation.responseString<html><head><title>Apache Tomcat/7.0.65 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /j-papakaka-web/indoorloc/locBuildingByIBeacon.ppkk</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/j-papakaka-web/indoorloc/locBuildingByIBeacon.ppkk</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.65</h3></body></html>

哪位大神知道,求指点迷津!感谢!

0 1

共收到1条回复

黑骑疯 656天前 #1楼

加入接收类型试试,text/html,application/json

0 评论

加入小组与大家一起讨论吧