iPhone app having trouble uploading to Google Docs (GData API)

I’m making an iPhone app that uses Google Docs. It can download docs fine, but uploading is a problem. When I try to get the URL for posting, it’s coming up empty. Here’s what I’ve got so far:

GDataFeedDocList *docFeed;   
Class entryClass = nil;

GDataEntryDocBase *newEntry = [entryClass documentEntry];
[newEntry setTitleWithString:docTitle];
[newEntry setUploadData:uploadData];
[newEntry setUploadMIMEType:mimeType];
[newEntry setUploadSlug:docTitle];

NSURL *postURL = [[docFeed postLink] URL];
NSLog(@"postURL = %@", postURL);

uploadTicket = [docService fetchDocEntryByInsertingEntry:newEntry
           forFeedURL:postURL 
             delegate:self
    finishSelector:@selector(uploadDone:finishedWithEntry:)
     failSelector:@selector(uploadFailed:withError:)];

The postURL is nil, so I can’t upload. Any ideas what I’m doing wrong?

I’ve run into similar issues when working with the GData API for Google Docs integration. One thing that helped me was ensuring I had the correct scope and authentication set up properly. Double-check that your OAuth2 credentials are configured correctly and that you have the necessary permissions for both read and write operations.

Also, make sure you’re fetching the document feed before trying to upload. The postURL should be derived from this feed. You might want to add some error handling to check if docFeed is nil before attempting to access its postLink.

Another tip: consider using the newer Google Drive API instead of GData if possible. It’s more robust and has better documentation. I switched to it in my last project and found it much easier to work with for similar functionality.

If you’re still stuck, try logging the entire docFeed object to see what data you’re actually receiving from Google. This could help pinpoint where things are going wrong in the process.

yo, i had this problem too. make sure ur docFeed isnt empty before tryin to get the postLink. also, check ur network connection - sometimes it’s just bad wifi messin things up. oh and double check ur using the right API version, they keep changing stuff. good luck!

Have you verified that your docFeed is actually populated before trying to access the postLink? It’s possible the feed isn’t being fetched correctly, which would explain the nil postURL. Try adding some debug logging right after you get the docFeed to ensure it contains the expected data.

Also, check your network connectivity when the app is trying to fetch the feed. Sometimes intermittent connection issues can cause this kind of problem. If you’re testing on a simulator, try using a real device to rule out any simulator-specific quirks.

Lastly, make sure your GDataServiceGoogleDocs object (I assume that’s what docService is) is properly authorized. Without the right authorization, you might get a feed without the necessary posting rights. Double-check your OAuth flow and ensure you’re requesting the correct scopes for both reading and writing to Google Docs.