0

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. enter image description here

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?

1 Answer 1

0

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();
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.