Friday, January 7, 2011

Google Docs API: Retrieving Contents of Root Folder

I have been working on a program that interacts with Google Docs, and the need came up to display the contents of the root folder. After some searching around, I found these queries that do what I want them to do (sort of):

Contents of root:
http://docs.google.com/feeds/default/private/full/folder%3Aroot/contents/

Only folders in root:
http://docs.google.com/feeds/default/private/full/folder%3Aroot/contents/-/folder

Everything but folders:
http://docs.google.com/feeds/default/private/full/folder%3Aroot/contents/-/-folder

The most useful one for me in my case was the first one. However, it did not work as I initially thought. I executed the query and I found items in the feed that were in folders. So after a bit of head scratching and searching I found the answer: both the root folder and the other misc folder(s) had an edit link to the file, so naturally it would show up in both feeds. In order to remove these from the root folder, you have to delete the edit link to it in that location.