ArcGIS Portal REST API -Upload a web map definition through the ArcGIS Portal REST API

7203
7
Jump to solution
11-07-2014 03:35 PM
MattMcGuire
Occasional Contributor

I'm trying to upload a web map definition to our ArcGIS Online Organizational Account through the ArcGIS Portal REST API. I'm using python to construct and issue the request. So far I can retrieve information about items, but I've yet to successfully use the AddItem Operation. I keep getting  "{"error":{"code":403,"messageCode":"GWM_0003","message":"You do not have permissions to access this resource or perform this operation.","details":[]}}

However, I am using the admin account, getting a token and can perform other operations, such as Item, to get a json definition of a web map.

Here is the URL:

https://<AGOL Organizational URL>/sharing/rest/content/users/<username>/addItem?f=json

Attached is a scrubbed version of the JSON I'm trying to post through the operation. Should this be allowed, and if so, is there a document available that shows what the JSON payload should look like to successfully use the addItem operation?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
HeikoHeijenga
Esri Contributor

Make sure you send a POST request, I just tried with your provided json and it works fine:

post.png

View solution in original post

7 Replies
HeikoHeijenga
Esri Contributor

Make sure you send a POST request, I just tried with your provided json and it works fine:

post.png

MattMcGuire
Occasional Contributor

Thanks Heiko,

I was able to construct a successful post using fiddler thanks to your post. What tool is it that you've pasted the screenshot from?


Matt

0 Kudos
HeikoHeijenga
Esri Contributor

That's Postman

0 Kudos
deleted-user-Jie3eyjOl9XM
Occasional Contributor

Matt,

I came across your question, because I want to create a webmap from json, too -- Without using the webmap GUI builder. I tried adding an item on AGO, and it thinks I'm adding geojson. If you use this technique, uploading through the AGO REST API, will I be able to access the webmap through the regular AGO map view?

AJ

0 Kudos
MattMcGuire
Occasional Contributor

It did make it work using that technique, but  you won't be able to access the web map, because I'd have to share it with you.

As Heiko Heijenga noted, he was able to post successfully using the JSON I provided. So I tried again and after some frustration was also able to post the JSON and found a valid web map in my AGOL account. Note that the non-basemap layer in my JSON does not show any data. The web map is OK, but  you might want to try it with your own basemap and layer.

The tool that Heiko linked is an easier way to "fiddle" with post requests than fiddler.

deleted-user-Jie3eyjOl9XM
Occasional Contributor

This is great! I used POSTMAN to generate a token, and and then upload a webmap, which I can view in the map view, and has an itemid! Thanks!

AdamJoseph1
New Contributor

another alternative to serve out webmapIDs is to parse your webmapID in Cartoview

0 Kudos