ios - Want to Create String to Post Method -
i want pass string in post method..
the string @"functionname=getcourses_by_category&json={"course_cat_id":"8"}"
from apple's docs on how send post data:
nsstring *bodydata = @"functionname=getcourses_by_category&json={\"course_cat_id\":\"8\"}"; nsmutableurlrequest *postrequest = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:@"https://www.apple.com"]]; // set request's content type application/x-www-form-urlencoded [postrequest setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"]; // designate request post request , specify body data [postrequest sethttpmethod:@"post"]; [postrequest sethttpbody:[nsdata datawithbytes:[bodydata utf8string] length:[bodydata length]]]; // initialize nsurlconnection , proceed usual
Comments
Post a Comment