我正在获取状态代码200以响应Web服务请求。使用[NSJSONSerialization JSONObjectWithData:data options:0 error:&error]
但是这个网络服务在Google Chrome的Postman上运行正常。 任何人都可以告诉我为什么它不能在代码中工作?
我的网络服务的响应(Post方法):
<NSHTTPURLResponse: 0x7fda63c82810> { URL: http://example.com/iphone/webservice.php?action=pagination } { status code: 200, headers {
Connection = "Keep-Alive";
"Content-Type" = "text/html";
Date = "Wed, 04 Nov 2015 06:11:30 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = "Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips";
"Transfer-Encoding" = Identity;
"X-Powered-By" = "PHP/5.4.27";
}
}
答案 0 :(得分:0)
因为您的回复是text/html
,而不是application/json
“Content-Type”=“text / html”;
因此,您应该尝试在application/json