HTTP GET in JSON within an API -


how http request of data in json format, 1 api endpoint , post api endpoint.

-(void)getrequest{

//init nsurlsession configuration nsurlsessionconfiguration *defaultconfigobject = [nsurlsessionconfiguration defaultsessionconfiguration]; nsurlsession *defaultsession = [nsurlsession sessionwithconfiguration: defaultconfigobject delegate: nil delegatequeue: [nsoperationqueue mainqueue]];  //create urlrequest nsurl *url = [nsurl urlwithstring:@"your url"]; nsmutableurlrequest *urlrequest = [nsmutableurlrequest requestwithurl:url];   [urlrequest sethttpmethod:@"get"]; [urlrequest setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"];  //create task nsurlsessiondatatask *datatask = [defaultsession datataskwithrequest:urlrequest completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) {     //handle response here    // nslog(@"resultsdictionary %@",response);   }];  [datatask resume]; 

}


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -