0

I'm in charge of moving our test Portal maps into production and looking for an easy way to get a list of all the layer sources in the web map. In addition it would be great to be able to export a text file with the widgets, and settings for that web app.

  • Have you used ago-assistant. You have access to the json describing the nature of all the web maps, layer, etc. You can even edit the json to update. You look 1 by 1. Python API would probably get you everything you are looking for in a more automated way. – timlohnes Sep 19 at 18:31
  • Hi Tim, I forgot about that. I had used it years ago, but remembered it was not a supported tool or workflow. I didn't realize people were still developing it! I tried to connect to my internal portal and it gave me an error on the URL... Any experience with that? – sofoo Sep 19 at 18:44
  • No experience with internal portal. Sorry. – timlohnes Sep 19 at 18:48
  • I've used ago-assistant just fine with an on-premise portal. Works well. Portal was using IWA. AGO-Assistant has come a long way. Not sure how to provide support beyond telling you the URL should just be like myserver.com/portal – KHibma Sep 19 at 19:04
  • I just read something about registering the app in portal to obtain an appId. Did you do this to get your portal url to work? – sofoo Sep 25 at 0:21
1

I would recommend using ESRI's ArcGIS API for Python. Once you have a WebMap object, you can find the layers from webmap.layers, and each layer object will have a url attribute.

You can leverage the Python API using Esri powered notebooks if you're more comfortable working in the web browser and copying code in from samples than writing complete Python scripts.

Update: per your comment, to copy a webmap from one portal to another, there is a good workflow example on this page. Some relevant code snippets:

def copy_item(target, source_item):
    try:
        with tempfile.TemporaryDirectory() as temp_dir:
            item_properties = {}
            for property_name in ITEM_COPY_PROPERTIES:
                item_properties[property_name] = source_item[property_name]

            data_file = None

            if source_item.type in TEXT_BASED_ITEM_TYPES:
                # If its a text-based item, then read the text and add it to the request.
                text = source_item.get_data(False)
                item_properties['text'] = text

            elif source_item.type in FILE_BASED_ITEM_TYPES:
                # download data and add to the request as a file
                data_file = source_item.download(temp_dir)

            thumbnail_file = source_item.download_thumbnail(temp_dir)
            metadata_file = source_item.download_metadata(temp_dir)

            #find item's owner
            source_item_owner = source.users.search(source_item.owner)[0]

            #find item's folder
            item_folder_titles = [f['title'] for f in source_item_owner.folders 
                                  if f['id'] == source_item.ownerFolder]
            folder_name = None
            if len(item_folder_titles) > 0:
                folder_name = item_folder_titles[0]

            #if folder does not exist for target user, create it
            if folder_name:
                target_user = target.users.search(source_item.owner)[0]
                target_user_folders = [f['title'] for f in target_user.folders
                                       if f['title'] == folder_name]
                if len(target_user_folders) == 0:
                    #create the folder
                    target.content.create_folder(folder_name, source_item.owner)

            # Add the item to the target portal, assign owner and folder
            target_item = target.content.add(item_properties, data_file, thumbnail_file, 
                                             metadata_file, source_item.owner, folder_name)

            #Set sharing (privacy) information
            share_everyone = source_item.access == 'public'
            share_org = source_item.access in ['org', 'public']
            share_groups = []
            if source_item.access == 'shared':
                share_groups = source_item.groups

            target_item.share(share_everyone, share_org, share_groups)

            return target_item

    except Exception as copy_ex:
        print("\tError copying " + source_item.title)
        print("\t" + str(copy_ex))
        return None

You would probably need to adjust this for your specific requirements, but it should point you in the right direction.

  • Thanks! This is great for the layer list. Looking around the api for something that can replicate the widget settings within a web app, or ability to copy a web app from test to prod. Don't see anything. Any advice there? – sofoo Sep 19 at 19:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.