Select to view content in your preferred language

How to get Folder ID from portal In ArcGis Pro SKD?

10-17-2017 11:26 AM
Occasional Contributor II

Using the ArcGIS Pro 2.0(1) how can I check if  a specific folder in my content exists, create it if not, and obtain its ID.

During publishing a Web Layer, I need as an optional parameter the FolderID - not the name!

new EsriHttpClient().Upload(portal.PortalUri.ToString(), layerItem, "my Layer Name", new[] {"myTag"}, "folderID");

0 Kudos
1 Reply
Esri Regular Contributor

At 2.1, call portal.GetUserContentAsync

var owner = portal.GetSignOnUsername();

var userContent = await portal.GetUserContentAsync(owner);

foreach (var pf in userContent.PortalFolders)


At 2.0, you have to execute the rest query directly for user content (via EsriHttpClient). The url would look like this:

var owner = portal.GetSignOnUsername();

var url = $"{portal.PortalUri.AbsoluteUri}/content/users/{owner}";

var response = new EsriHttpClient().Get(url);

var json = await response.Content.ReadAsStringAsync();

The returned json will contain your folders. See Rest API User Content