Geographic Information Systems Asked by Losbaltica on November 1, 2020
I am quite new with ArcGIS Online and their .Net SDK.
I am trying to load shapefile into my ArcGIS online account using .Net SDK.
On the ESRI tutorial portal, there is 0 information about it, all is focused around WPF technology.
From what I heard, the Esri .Net SDK have complete integration with ArcGIS Online portal, but I cannot find any documentation of how to use this SDK with Online server. Did anyone manage to actually do it?
Apparently is not that hard to do.
ESRI provided another guide documents for .Net SDK here
Following their tutorial simply shp import will look as follow:
public async Task PublishShp()
{
// All shp files needs to be pack into ZIP
const string filePath = "C://test.zip";
const string portalFileName = "test";
var organizationUri = new Uri("https://www.arcgis.com/sharing/rest/");
// Create credential token
var cred = await AuthenticationManager.Current.GenerateCredentialAsync(
organizationUri,
_userName,
_password) as ArcGISTokenCredential;
// connect to the portal, pass in the token
var portal = await ArcGISPortal.CreateAsync(
organizationUri,
cred,
CancellationToken.None);
// Create portal item object
var item = new PortalItem(portal, PortalItemType.ShapeFile, portalFileName);
// All shp files into be zip into single file
var data = new FileStream(filePath, FileMode.Open);
var mediaType = new MediaTypeHeaderValue("application/octet-stream");
var content = new PortalItemContentParameters(data, portalFileName, mediaType);
await portal.User.AddPortalItemAsync(item, content);
data.Close();
}
Answered by Losbaltica on November 1, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP