Create Simple Web Map via API REST

2630
5
04-03-2018 09:09 AM
PilarArregui
New Contributor II

Following the instructions on this page Working with users, groups, and items—ArcGIS REST API: Users, groups, and content | ArcGIS for Devel... I was able build a POST request in POSTMAN  to add a new item to the user.

After getting the token, when I try the POST request to add the web map I get this error

{"error":{"code":403,"messageCode":"GWM_0003","message":"You do not have permissions to access this resource or perform this operation.","details":[]}}

The JSON I used is this:

{
"operationalLayers": [],
"baseMap": {
"baseMapLayers": [
{
"id": "defaultBasemap",
"layerType": "ArcGISTiledMapServiceLayer",
"url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
"visibility": true,
"opacity": 1,
"title": "Topographic"
}
],
"title": "Topographic"
},
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
},
"authoringApp": "WebMapViewer",
"authoringAppVersion": "5.4",
"version": "2.11"
}

0 Kudos
5 Replies
AnthonyRyanEQL
Occasional Contributor III

Pilar,

The username you are using in AGOL, does it have the right role assigned that allows content to be created. Can you create & save a webmap using the standard menuitems in AGOL using this username?

0 Kudos
PilarArregui
New Contributor II

Hi Ryan, 
The username I'm using in AGOL is an ArcGIS developer account. As far as I know this kind of user has an admin role and all permissions available. And I can create a WebMap in the ArcGIS webpage without problems.

0 Kudos
PilarArregui
New Contributor II

Turns out I was using the wrong access token. I was using the app access token instead of the user access token. 

With the user access token it works now.

JackSilburn
New Contributor III

Hi Pilar

Can you describe this last step in more detail? I believe I am facing a similar issue?

0 Kudos
Yik-ChingTsui
New Contributor III

I had this problem too. Turns out you need an OAuth token and not the token from generateToken. The code I used is here: https://gist.github.com/YikChingTsui/ff6d7b6126db73a77e5845576250177d

0 Kudos