Hey guys,
I am trying to develop a Halo 5 stats app for my iOS programming class and have had an issue connecting using the code given in the documentation. Specifically, the first thing I wish to retrieve is an emblem for my spartan and I am getting the same errors. Here are the errors i get:
NSErrorFailingURLStringKey=https://www.haloapi.com/profile/h5/profiles/ArsonHoliday/emblem, NSErrorFailingURLKey=https://www.haloapi.com/profile/h5/profiles/ArsonHoliday/emblem, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-4, NSLocalizedDescription=The network connection was lost.}
2016-04-06 15:21:09.413 h5stats[10991:936959] _BSMachError: (os/kern) invalid capability (20)
2016-04-06 15:21:09.413 h5stats[10991:936959] _BSMachError: (os/kern) invalid name (15)
I know my subscription key is valid, and when I use the try it button in the documentation, it seems like that url should be valid. Here is the code:
NSString* path = [NSString stringWithFormat:@“https://www.haloapi.com/profile/h5/profiles/%@/emblem”, item.gamertag];
//optional parameter for emblem size, not using
/*
NSArray* array = @[
// Request parameters
@“entities=true”,
@“size=95”
];
//@“size={number}”,
/
//NSString string = [array componentsJoinedByString:@"&"];
//path = [path stringByAppendingFormat:@"?%@", string];
// NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@“GET”];
// Request headers
[_request setValue:@"{sub key}" forHTTPHeaderField:@“Ocp-Apim-Subscription-Key”];
// Request body
[_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError error = nil;
NSData _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
What is {body} supposed to contain? and am I supposed to fill that? I also ran the python code and it worked in Terminal, but it didn’t seem to be doing anything with {body} either.
Followed by some error handling. If anyone has any iOS/Objective C experience and has the time to help my out, I’d be very grateful.
Thanks,
A fellow Spartan