Select to view content in your preferred language

Upload csv to portal

329
8
Jump to solution
a month ago
MK13
by
Frequent Contributor

Is it possible to upload a csv file to portal or create a feature service using the pro sdk? I couldn't find any samples in the documentation.

@CharlesMacleod @UmaHarano @Wolf 

0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

Hi @MK13 

Here is a code snippet - I will add this to our docs too for posterity.

// Create EsriHttpClient object
   var httpClient = new EsriHttpClient();
 
   // Upload CSV file to ArcGIS Online
   var itemToUpload = ItemFactory.Instance.Create(@"C:\Data\AddToMapCustomItem\AlaskaCitiesXY.csv");
   string[] tags = new string[] { "ArcGIS Pro", "SDK", "Internal Demo" };
   UploadDefinition uploadDefinition = new UploadDefinition(
     ArcGISPortalManager.Current.GetActivePortal().PortalUri.ToString(),
     itemToUpload,
     tags
     );
   var result = httpClient.Upload(uploadDefinition);
 
   if (result.Item1 == false)
     return;
 
   Thread.Sleep(2000);

View solution in original post

8 Replies
UmaHarano
Esri Regular Contributor

@MK

Can you please explain a little more? You have custom data in a csv?

0 Kudos
MK13
by
Frequent Contributor

@UmaHarano yes. I have custom data that I generate in a pro sdk addin that I would like to save to ArcGIS Portal either as a csv file or a feature service.

0 Kudos
UmaHarano
Esri Regular Contributor

@MK13 

As you might already know, a plugin data cannot be shared as a web layer.

But, a csv file can be shared to an ArcGIS Enterprise portal- Here is a document that lists all the supported items on an  ArcGIS Enterprise portal:
Content you can add in the ArcGIS Enterprise portal 

0 Kudos
MK13
by
Frequent Contributor

@UmaHarano do you have some example code to share a csv file to portal using the pro sdk?

0 Kudos
UmaHarano
Esri Regular Contributor

@MK13 

You will have to use EsriHttpClient to upload the csv file. I don't have a code snippet for it yet - will try and share some code in the next couple days.

MK13
by
Frequent Contributor

Hi @UmaHarano , have you had a chance to find a code snippet for an upload to portal? The documentation has lots of examples for get requests but no post examples.

0 Kudos
UmaHarano
Esri Regular Contributor

Hi @MK13 

Here is a code snippet - I will add this to our docs too for posterity.

// Create EsriHttpClient object
   var httpClient = new EsriHttpClient();
 
   // Upload CSV file to ArcGIS Online
   var itemToUpload = ItemFactory.Instance.Create(@"C:\Data\AddToMapCustomItem\AlaskaCitiesXY.csv");
   string[] tags = new string[] { "ArcGIS Pro", "SDK", "Internal Demo" };
   UploadDefinition uploadDefinition = new UploadDefinition(
     ArcGISPortalManager.Current.GetActivePortal().PortalUri.ToString(),
     itemToUpload,
     tags
     );
   var result = httpClient.Upload(uploadDefinition);
 
   if (result.Item1 == false)
     return;
 
   Thread.Sleep(2000);
MK13
by
Frequent Contributor

Works perfectly. Thanks!

0 Kudos