How to Save FeatureCollection to Portal Using SaveAsAsync

08-17-2017 12:03 AM
New Contributor III

Hi, Could you show the whole workflow to save FeatureCollection to Portal ?

Tags (1)
0 Kudos
2 Replies
Occasional Contributor III

Hi Yan,

I have used one of the existing sample, "FeatureCollectionLayerFromQuery", modified it to save the created feature collection from the feature layer (Layer: Wildfire Response Points (ID: 0) ) to the portal. Before using FeatureCollection.SaveAsAsync() method, you need to log in to the portal as below. Attached is the complete project. Once the code is executed, you will see a new item named, "Feature Collection to Portal" is added in the portal that copies all the features from the feature layer.

var tokenServiceUri = new Uri(""); // url for generating token

AuthenticationManager authManager = AuthenticationManager.Current;
var cred = await authManager.GenerateCredentialAsync(tokenServiceUri, "<portal_user_name>", "<portal_password>");

// Open a portal item containing a feature collection
ArcGISPortal portal = await ArcGISPortal.CreateAsync(tokenServiceUri, cred);

FeatureCollectionLayer featCollectionTable = new FeatureCollectionLayer(featCollection);
await featCollectionTable.LoadAsync();

List<string> str = new List<string>();
str.Add("Save Feature collection");

await featCollection.SaveAsAsync(portal, null, "Feature Collection to Portal", "FeatureCollection", str);
MessageBox.Show("Feature Collection saved to portal");

catch(Exception ex)

Hope that helps.


0 Kudos
New Contributor III

Thanks, Nagma

0 Kudos