What is the correct way to create a new PortalItem of type FeatureService?
I am logged in with a Publisher account and have tried following methods:
var portalItem = new PortalItem( portal, PortalItemType.FeatureService, "NewFeatureService");
await portal.User.AddPortalItemAsync(portalItem);
I get the exception:
Esri.ArcGISRuntime.Http.ArcGISWebException: ''url' parameter is required for this type.'
Where should i define the url parameter?
Also I have followed other example from the community and create a portal item based on a feature collection.
var featureLayerUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0";// Create a service feature table to get features from
var serviceFeatureTable = new ServiceFeatureTable(new Uri(featureLayerUrl));// Create a query to get all features in the table
QueryParameters queryParams = new QueryParameters {WhereClause = "1=1"};// Query the table to get all features
var featureQueryResult = await serviceFeatureTable.QueryFeaturesAsync(queryParams);// Create a new feature collection table from the result featuresvar featureCollectionTable = new FeatureCollectionTable(featureQueryResult)
{
Renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 8)),DisplayName = "Table Name"
};// Create a feature collection and add the table
var featureCollection = new FeatureCollection();
featureCollection.Tables.Add(featureCollectionTable);await featureCollection.LoadAsync();var tags = new List<string> {"Save Feature collection"};
await featureCollection.SaveAsAsync(portal, null, "Feature Collection to PortalItem", "FeatureCollection", tags);
In this case i can see the new FeatureLayer in my ArcGIS Online content page. I can see the geometry and the data in the map viewer.
But in this case the layer name on the details page is set as "Undefined", and when i publish it (with the ArcGIS web interface) the new created FeatureLayer (hosted) is empty.
Is there a way to publish the portal item similar to the rest api?
Any help would be greatly appreciated
Creating layer portal items from the Runtime aren't supported at this point (I believe only Maps are supported at this point via the Map.SaveAs method).