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 -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -