'file' - ArcGIS REST API - For ArcGIS Online

10-06-2014 12:29 PM
Occasional Contributor III


I am attempting to use the REST API for ArcGIS Online.

I have been successful in adding some general items through code, but I would like to now upload a map package using the API.

I am using the 'AddItem' function and am applying the 'file' parameter in my POST request (I also make it multipart)

What I am wondering what do I pass as a value for the 'file' parameter when trying to upload a file such as a map package?

Do I pass a local path: c:\temp\test.mpk

Do I pass a Base64 string ?

Do I pass some sort of byte array?

I have tried many different methods, but none are working.

Any ideas would be helpful.



0 Kudos
2 Replies
Occasional Contributor III

I was able to figure this out.. It was not as simple as I expected but it can be done.

Basically I had to create a Multipart Form Post in .NET

There is a nice C# Class someone wrote to assist with this here: Multipart Form Post in C# - Brian Grinstead


Occasional Contributor II

In non-GIS file via form, you send a file like this:

<form action="/upload" enctype="multipart/form-data" method="post" accept="image/*;caputre=camera">

<input type="file" name="upload" multiple="multiple"><br>

<input type="submit" value="Upload">


This is a sample I use for sending images from a computer to the server or opening the camera on a cell phone(so you probably don't need the accept= part unless you want to filter allowed filetype). The server should already be setup to handle the upload.

The link you posted says you can upload a zip or map package

Zip file (*.mpk, *.lpk)
|-- esriinfo (folder)
  |-- iteminfo.xml (item card)
  |-- subfolder
  |-- thumbnail.jpg