Instagram API responds with 400 (Bad Request)

I sent this URL via a message:

https://api.instagram.com/v1/users/XXX/relationship?action=unfollow&access_token=YYY

XXX is a valid user id, I checked it several times. Token (YYY) is also correct.

This is the answer:

{"meta":{"error_type":"APIInvalidParametersError","code":400,"error_message":"please supply action=approve,ignore,follow,block,unblock,unfollow"}}

I tried action = follow and action = unfollow. Is it possible that this is a mistake? Where can I report this?

API documentation: http://instagram.com/developer/endpoints/relationships/

+5
source share
3 answers

The problem is that you are not submitting the action as postdata. I had the exact problem just yesterday.

Access_token must be sent in the url, but action = follow must be in the postdata of the request!

+7
source
NSString *initialURL = [NSString stringWithFormat:@"https://api.instagram.com/v1/users/USER_ID/relationship?access_token=ACCESS TOKEN"];
NSURL *url=[NSURL URLWithString:initialURL];

NSString *key = [NSString stringWithFormat:@"action=follow"];
NSData *mastData = [key dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *mastLength = [NSString stringWithFormat:@"%d",[mastData length]];

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:mastLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:mastData];
NSURLConnection *con=[[NSURLConnection alloc]initWithRequest:request delegate:self];
[con start];
+1

Also make sure that you use the correct scope for authentication.

Add scope=like+comments+relationshipsauthentication to this URL.

0
source

All Articles