mgbpascual
mgbpascual

Reputation: 116

Unable to post a photo using the Tumblr SDK example

I'm trying to upload a photo using the example: PhotoPostExample given by Tumblr (https://github.com/tumblr/TMTumblrSDK)

I can't seem to upload a photo. I can already post a text post and view the user info, so I think the app is already authenticated. I've already checked if the photo referred to in the NS Bundle exists, and it does. I've even reduced the photo to make it smaller in file size and still it won't upload.

It shows this error:

Error Domain=Request failed Code=401 "The operation couldn’t be completed. (Request failed error 401.)"

Here's the code inside postphoto given by Tumblr that I used:

 [[TMAPIClient sharedInstance] photo:@"blogname"
                      filePathArray:@[[[NSBundle mainBundle] pathForResource:@"blue" ofType:@"png"]]
                   contentTypeArray:@[@"image/png"]
                      fileNameArray:@[@"blue.png"]
                         parameters:@{@"caption" : @"Caption"}
                           callback:^(id response, NSError *error) {
                               if (error)
                                   NSLog(@"Error posting to Tumblr %@", error);
                               else
                                   NSLog(@"Posted to Tumblr");
                           }];

Your help is very much appreciated! - Misheal

Upvotes: 0

Views: 1001

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89509

You're looking at the "error" parameter in your callback, that's good.

But if you want even more useful detail, parse the JSON response and you might end up getting to see something like:

(NSDictionary *) $1 = 0x0715df70 {
    meta = {
       msg = "Not Authorized";
       status = 401;
    };
response = ( );
}

I suspect you are not as authenticated as you think you were.

Upvotes: 2

Related Questions