cURL request in Objective-C (POST) cURL request in Objective-C (POST) curl curl

cURL request in Objective-C (POST)


Check the code snippet out below that should definitely help.

NSString *Post = [[NSString alloc] initWithFormat:@"{Page:0, Take:10}"];NSData *PostData = [Post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];NSURL *url = [NSURL URLWithString:@"http://data.leafly.com/strains"];NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];[req setHTTPMethod:@"POST"];[req addValue:@"a2eaffe2" forHTTPHeaderField: @"app_id"];[req addValue:@"49588984075af3d275a56c93b63eedc0" forHTTPHeaderField:@"app_key"];[req setHTTPBody:PostData];NSData *res = [NSURLConnection  sendSynchronousRequest:req returningResponse:NULL error:NULL];NSString *myString = [[NSString alloc] initWithData:res encoding:NSUTF8StringEncoding];NSLog(@"%@", myString);