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

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -