Getting nil URL when uploading files to Google Drive using GData library on iOS

I’m building an iOS app that works with Google Drive documents using the GData framework. I can successfully retrieve and display documents from Google Drive, but I’m stuck on the file upload functionality.

The main issue is that when I try to get the upload URL using the postLink method, it returns nil. This prevents me from uploading any files to Google Drive. Here’s the code I’m using:

GDataFeedDocList *documentFeed;
Class entryClass = nil;

GDataEntryDocBase *newEntry = [entryClass documentEntry];
[newEntry setTitleWithString:self.fileName];
[newEntry setUploadData:self.fileData];
[newEntry setUploadMIMEType:mimeType];
[newEntry setUploadSlug:self.fileName];

NSURL *uploadURL = [[self.documentFeed postLink] URL];
NSLog(@"Upload URL: %@", uploadURL);

self.uploadTicket = [googleService fetchDocEntryByInsertingEntry:newEntry
                                                      forFeedURL:uploadURL
                                                        delegate:self
                                               didFinishSelector:@selector(uploadComplete:finishedWithEntry:)
                                                 didFailSelector:@selector(uploadFailed:failedWithError:)];

The uploadURL variable is always nil, which makes the upload fail. Has anyone encountered this issue before? What could be causing the postLink to return nil?

yea, that sounds like the issue! make sure documentFeed is loaded first. I had to wait for the feed to load completely b4 calling postLink, or it gave me nil too. good luck!

This happens when your authentication scope doesn’t include write permissions. You can read documents fine, but uploading needs different access rights. Make sure your OAuth scope covers the full Google Drive API, not just read-only. I ran into this same issue and wasted hours debugging that nil postLink before I figured out my app was only authorized to view documents. You’ve got to request write permissions when users first authenticate. Also double-check that your GDataServiceGoogleDocs instance has the auth token properly set before trying to hit the upload URL.

Had the same issue with GData uploads. You’re probably trying to access postLink before documentFeed has actually loaded from the server. Make sure your documentFeed is fully populated with data from Google Drive before grabbing the upload URL. I had to change my flow so uploads only happen after the feed fetch completes successfully. Check if documentFeed is actually populated - log the entries count or other properties. If it’s empty or half-loaded, that’s why postLink returns nil. GData needs a fully loaded feed to give you the right upload endpoints.