Originally used to be application/json this format, do iOS commonly used network request framework afnetworking, the default is also Application/json, not long ago encountered this acceptance format problem, according to various statements on the Internet, Changed the afnetworking settings, eventually still can not solve the problem, and finally abandoned the use of afnetworking. Writing a native Web request solves the problem.
The code is as follows:
1Nshttpurlresponse *response =Nil;2 3Nserror *erro =Nil;4 5Nsmutableurlrequest *request =[[Nsmutableurlrequest Alloc]initwithurl:[nsurl Urlwithstring:urlstr]];6 7Request. HttpMethod =@"POST";8Set format9[Request AddValue:@"application/x-www-form-urlencoded; Charset=utf-8"Forhttpheaderfield:@"Content-type"];Ten// One[Request AddValue:@"2"Forhttpheaderfield:@"X-wh-token"]; AEncrypt with HMAC -NSString *serkey = [NSString hmacsha1:@""Key:key]; - the[Request Addvalue:serkey Forhttpheaderfield:@"x-wh-signature"]; - - [Request Sethttpbody:[body datausingencoding:nsutf8stringencoding]; - +NSData *requesdata = [nsurlconnection sendsynchronousrequest:request returningresponse:&response Error:&erro ];
Application/x-www-form-urlencoded of iOS development; charset=utf-8