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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -