ios - NSURLRequest HTTPBody vs. ASIHTTPRequest postBody -
i'm trying convert of project's nsurlrequests use nsurlconnection asihttprequest calls. came across issue setting httpbody in asihttprequest. here's had nsurlrequest call:
nsmutableurlrequest *req = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:self.urlstring]]; [req sethttpmethod:@"post"]; [req sethttpbody:[self.paramstring datausingencoding:nsutf8stringencoding]]; [self _sendrequest:req];
and convert asi, have far:
__block asihttprequest *request = [asihttprequest requestwithurl:[nsurl urlwithstring:self.urlstring]]; [request setrequestmethod:@"post"]; [request appendpostdata:[self.paramstring datausingencoding:nsutf8stringencoding]]; [request setcompletionblock:^{ nslog(@"asihttp request finished: %@", [request responsestring]); // stuff here }]; [request setfailedblock:^{ nserror *error = [request error]; nslog(@"asihttp error: %@", [error description]); }]; [request startasynchronous];
although when run asi, error:
asihttp error: error domain=asihttprequesterrordomain code=6 "unable start http connection" userinfo=0x10ddf6b0 {nslocalizeddescription=unable start http connection}
edit error fixed, data still not being transmitted correctly due body not being set.
i'm thinking has me not setting body correctly. tried using asi's setpostbody, produced same result. works fine nsurlrequest, not asi. i'm pretty sure it's simple , haven't explored asi's full library quite yet, wondering if had suggestions. have read documentation, couldn't find looking for.
thanks!
could check that
self.paramstring
is correct? how like?
Comments
Post a Comment