How to modify web map URL of a published web mapping app

09-05-2018 04:52 PM
New Contributor II

I have a bunch of web mapping applications that have been copied from one portal into another.  In the process, the URL for the Web Map that backs the web mapping application is simply copied from the source portal.  I need to be able to modify the URL of the Web Map in the destination portal's Web Mapping Application.  I have searched high and low and cannot find out how one would accomplish this.  ArcGIS Online Assistant doesn't do it, and I would prefer to do it via Python anyway, whether through the ArcGIS API for Python or via the REST API.  

I thought I was making progress by getting the item's data from the source ( the_item.get_data() from the API for Python), editing it, and then publishing it.  I am using some code from Esri found on the 'net, with a function that adds the item, but it also needed the item's description which is obtained via the REST API at the ../sharing/rest/content/items/itemID endpoint of the source Web Mapping App.  I then edit that description dictionary and add the item to the destination portal via the code from Esri, but I can't figure out how to set the new Web Mapping App's web map URL without ruining the URL for the Web Mapping App itself.  It ends up using the same URL for both the Web Map AND the Web Mapping Application, which means if you click "View Application" on the new Web Mapping Application it actually takes you to the Web Map's URL instead of opening the Web Mapping Application.

Here's the function I use to get the source item's description:

def addItem(username, folder, description, data, portalUrl, token, thumbnailUrl=''):
    '''Creates a new item in a user's content.'''
    description = json.dumps(description).replace('None', '')
    parameters = urllib.parse.urlencode({'item': json.loads(description)['title'],'text': data, 'overwrite': 'true', 'thumbnailurl': thumbnailUrl, 'token' : token, 'f' : 'json'})
    postParameters = urllib.parse.urlencode(json.loads(description)) + '&' + parameters
    postParameters = postParameters.encode("utf-8")
    the_request = urllib.request.urlopen(portalUrl + '/sharing/rest/content/users/' + username + '/' + folder + '/addItem?', postParameters)
    response =
    return response

Since documentation is not exactly user friendly and examples are nonexistent I'm not sure I was even on the right track.  Maybe there's a far easier way to do this.  I'm all ears!

0 Kudos
2 Replies
New Contributor II

Looks like this can actually be done in ArcGIS Online Assistant in a fairly un-user-friendly fashion by viewing and editing Web Mapping Applications' JSON.  It seems to work, but it's unsupported and a little  dangerous.

Using the same method that AGO Assistant does, I may be able to get my Python script to do the job.

0 Kudos
Occasional Contributor III


Have you succeeded with updating Web Mapping App itemId? 

0 Kudos