I've been trying to query Tesco's API Service. Although I've managed comfortably on Python with this, I have been having some trouble with making a request using Objective C. Nothing is being logged on the output. Any help would be appreciated. The program code is shown below:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSURLSessionConfiguration *defaultSessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration:defaultSessionConfiguration];
NSURL *url = [NSURL URLWithString:@"https://dev.tescolabs.com/product/?gtin=4548736003446"];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
NSString *postParams = @"subscription key=93a6e21eed2e4ca3a858a0f1fc5aaf03";
NSData *postData = [postParams dataUsingEncoding:NSUTF8StringEncoding];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setHTTPBody:postData];
NSURLSessionDataTask *dataTask = [defaultSession dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"Response: %@",response);
NSLog(@"Data: %@",data);
NSLog(@"Error: %@",error);
}];
[dataTask resume];
}
return 0;
}