Reputation: 1
I am writing an app in iOS that integrates to Instagram. I am getting an Http Error 400 from Instagram when using the Like API call. The other API calls are working fine however. Here is part of my code where I post the request
{
NSDictionary* params = [NSDictionary dictionaryWithObject:_accessToken forKey:@"access_token"];
NSString* path = [NSString stringWithFormat:kUserLikeEndPoint, medID];
NSURL *url = [NSURL URLWithString:path relativeToURL:[NSURL URLWithString:kInstagramBaseURLString]];
NSMutableArray *mutableParameterComponents = [NSMutableArray array];
for (NSString *key in [params allKeys]) {
NSString *component = [NSString stringWithFormat:@"%@=%@", [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[[params valueForKey:key] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[mutableParameterComponents addObject:component];
}
url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", [mutableParameterComponents componentsJoinedByString:@"&"]]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:defaultHeaders];
likeInstagramConnection = [NSURLConnection connectionWithRequest:request delegate:self];
}
It is during this connection that I get the following Error
Error Domain=HTTP Code=400 "HTTP Error" UserInfo=0xd9571b0 {NSLocalizedDescription=HTTP Error} desc <NSHTTPURLResponse: 0xd9574a0> { URL: https://api.instagram.com/v1/media/632580883841234624_257450972/likes?access_token=ACCESS_TOKEN_GOES_HERE } {
status code: 400, headers {
Connection = "keep-alive";
"Content-Language" = en;
"Content-Length" = 92;
"Content-Type" = "application/json; charset=utf-8";
Date = "Tue, 28 Jan 2014 07:17:52 GMT";
Server = nginx;
"Set-Cookie" = "csrftoken=5eaa89da550811f9d62d5c15525ceebf; expires=Tue, 27-Jan-2015 07:17:52 GMT; Max-Age=31449600; Path=/, ccode=US; Path=/";
Vary = "Cookie, Accept-Language";
"X-Ratelimit-Limit" = 5000;
"X-Ratelimit-Remaining" = 4997;
}
}
Upvotes: 0
Views: 1029
Reputation: 1012
Might be an expired access token. I know in python I am getting this error code in an API call exception, and I can't see why they would make status codes differ between languages. Hope that gets you in the right direction.
Upvotes: 0