Hello all, I am trying to upload a photo from an iPhone application, so I am following the documentation on the protocol (http://code.google.com/ apis/picasaweb/docs/2.0/developers_guide_protocol.html).
1. sent a ClientLogin request to get the "Auth" value (OK !) 2. sent POST to "http://picasaweb.google.com/data/feed/api/user/ test.isi.pf/albumid/5393007209325199649" with : Authorization and Slug header, and the data in the Body. I keep getting a HTTP 403 error with the message "Modification only allowed with api authentication.". Anybody has any clue why I am getting this or what I can do as alternative to this ? Here's the code I wrote : - (void) storeImageToPicasaWeb:(NSData*)imageData { NSString * auth = [self loginToGoogle:@"[email protected]" password:@"xxxxx" service: @"lh2" accountType: @"GOOGLE"]; NSLog(@"auth value = %@", auth); NSString * urlString = @"http://picasaweb.google.com/data/feed/api/ user/test.isi.pf/albumid/5393007209325199649"; NSURL *url = [[NSURL alloc] initWithString:urlString]; NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30]; NSString* authorizationString = [NSString stringWithFormat:@"GoogleLogin auth=%@",auth]; [urlRequest setValue:authorizationString forHTTPHeaderField:@"Authorization"]; [urlRequest setValue:@"2" forHTTPHeaderField:@"GData-Version"]; // post without metadata [urlRequest setValue:@"test.jpg" forHTTPHeaderField:@"Slug"]; [urlRequest setValue:@"image/jpeg" forHTTPHeaderField:@"Content- type"]; NSString* contentLengthString = [NSString stringWithFormat:@"%d", [imageData length]]; [urlRequest setValue:contentLengthString forHTTPHeaderField:@"Content- length"]; [urlRequest setHTTPMethod:@"POST"]; [urlRequest setHTTPBody:imageData]; // Fetch the response NSData *urlData; NSHTTPURLResponse *response; NSError *error; // Make synchronous request urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error]; NSLog(@"http response code : %d", [response statusCode]); NSLog(@"content-length : %d", [urlData length] ); NSString * responseString = [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding]; NSLog(@"response : %@", responseString); } The output of that execution : 2009-10-16 08:42:48.295 RestoIPhone[32179:20b] auth value = DQAAAHkAAABUblbxQUKpQOMcipKOpNklXjzVos19CFfhTWWRIgEwjXD21vDGh0HeSMXnNSZLhQ4IMH_Zza5OuhG0ClD6zILtRxGMRgv21sfbfQFqRQl49GxZe4fHpk38pMBwxcOGWaLHxWOOxVjraKCV- D2rOR4P7HkmsCMwdXTWswj29p_slg 2009-10-16 08:42:51.587 RestoIPhone[32179:20b] http response code : 403 2009-10-16 08:42:51.588 RestoIPhone[32179:20b] content-length : 50 2009-10-16 08:42:51.589 RestoIPhone[32179:20b] response : Modification only allowed with api authentication. 2009-10-16 08:42:51.589 RestoIPhone[32179:20b] done didFinishPickingMediaWithInfo() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Picasa Web Albums API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-picasa-data-api?hl=en -~----------~----~----~----~------~----~------~--~---
