c# - iOS http POST request -


i have api on server trying json response from. have used several request tools simulate call, , correct data each time. here request setup:

nsstring *post = [nsstring stringwithformat:@"user_id=%@&last_sync=%@",user_id, last_sync]; nsurl *directoryurl = [nsurl urlwithstring:directoryuri]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:directoryurl];  [request sethttpmethod:@"post"]; [request setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"]; [request sethttpbody:[nsdata datawithbytes:[post utf8string] length:[post length]]]; 

the content type same on simulated requests. there no errors returned, no content.

i use afnetworking library, takes lot of pain out of http comms.

my post calls along lines below:

nsurl *nsurl = [nsurl urlwithstring:@"http://someurl.com"]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:nsurl];  [request sethttpmethod:@"post"]; [request addvalue:@"xxxx" forhttpheaderfield:@"yyy"]; // header params want pass in [request addvalue:@"application/json" forhttpheaderfield:@"content-type"]; [request addvalue:@"application/json" forhttpheaderfield:@"accept"];  // if need pass json data ws if (json != nil) [request sethttpbody:json];  afjsonrequestoperation *operation = [afjsonrequestoperation jsonrequestoperationwithrequest:request success:^(nsurlrequest *returnedrequest, nshttpurlresponse *response, id json) {     ... } failure:^(nsurlrequest *returnedrequest, nshttpurlresponse *response, nserror *error, id json) {        ... }]; 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -