Portal getFolders not returning root folder

735
1
11-22-2013 01:08 PM
BillGrow
New Contributor II
Hi,

While retrieving portal items through the API, using loggedInUser.getFolders() then looping through those folders with loggedInUser.getItems(folder.id), I've noticed I dont get any items that are in the root (Home) folder, ie. items not in a folder.

The "Home" folder does not appear to be in the .getFolders() response, so I am wondering how I find this ID to get it's items.

Thanks,
~Bill
0 Kudos
1 Reply
JianHuang
Occasional Contributor III
You are right, getFolders() doesn't return the root folder.
You can fetch the root folder by using the URL directly. For example, the following code snippet shows how to add an item to the root folder.
var userContentUrl = user.portal.url + "/content/users/" + user.credential.userId,
  folderUrl;
if ("Want to save to the root folder") {
          folderUrl = userContentUrl;
        } else {
          folderUrl = userContentUrl + "/" + folderId;
        }
var request = esri.request({
          url: folderUrl + "/addItem",
          content: item
        }, {
          usePost: true
        });
        request.then(requestSucceeded);
0 Kudos