Objective-C Post request send no data -
i'm trying send post request url
but server empty data
nsstring *post = [nsstring stringwithformat:@"cmd=login&account=%@&password=%@" ,account ,password]; nsdata *data = [post datausingencoding:nsasciistringencoding]; nsmutabledata *postdata = [data mutablecopy]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request seturl:[nsurl urlwithstring:[nsstring stringwithformat:@"http://myurl.com"]]]; [request sethttpmethod:@"post"]; [request sethttpbody:postdata]; nserror *error = nil; nshttpurlresponse* urlresponse = nil; nsdata *returndata = [nsurlconnection sendsynchronousrequest:request returningresponse:&urlresponse error:&error]; nsstring *returnstring = [[nsstring alloc] initwithdata:returndata encoding:nsasciistringencoding]; nslog(@"%@", returnstring); nslog(@"error: %@", error.localizedfailurereason);
here response
2014-08-18 17:21:52.332 signpos[2755:303] {"resp":99,"desc":"invalid cmd"}
2014-08-18 17:21:52.333 signpos[2755:303] error: (null)
is there wrong?
thanks!
Comments
Post a Comment