1

I'm using Python to build an ArcGIS Online web map definition JSON string, and then trying to post the configuration to ArcGIS Online to create a web map. I am using an admin account to generate the token and can perform other functions, but I get an error that says the user don't have permission to do this operation. I get the impression that this should be possible through the AddItem Operation . Below is the python function in which I'm attempting to post the web map def.

Can anyone confirm this is possible? If so, maybe I'm just formatting the JSON or request incorrectly.

def publishWebMapDef(sTitle, user, sWebMapDef, token):
    #sWebMapDef is a json string that mimics the item data returned from the Item Data operation http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Item_Data/02r300000075000000/
    params = {"token": token, "title": sTitle, "type": "Web Map", "description":"Test Add Item", "snippet":"This is the snippet","tags": "test", "text":sWebMapDef}
    root_url = AGOL + "sharing/rest"
    Content_Root = root_url + "/content"
    User_Content = Content_Root + "/users/" + user
    AddItemurl = User_Content + '/addItem'
    url = urljoin(AddItemurl, '?f=json')
    sParams =json.dumps(params)

    headers = {'content-type': 'application/json'}
    r = requests.post(url, data=json.dumps(params),headers=headers)
  • Just a note to follow Python Pep 8 when you're coding in python. Here's a handy dandy pep-8 checker – dassouki Nov 21 '14 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.