Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

Setting a default basemap in Portal #224

Closed SergStol closed 8 years ago

SergStol commented 8 years ago

I want to configure a default basemap through ArcREST, is this possible? I can see in administration._portals there is ways to get defaults basemaps. No methods to change this though.

achapkowski commented 8 years ago

@SergStol you need to update the portal properties through the Portal class.

I believe the issue is Portal.update() is the function.

SergStol commented 8 years ago

Thanks a lot for the pointer! I have managed to construct a workflow to do this. As currently there is a bug in Portal where you cant set up your default basemap in the settings. Works fine in AGOL.

Here is the code that worked for me to inject a basemap json into Portal to use as default basemap:

import arcrest import json

securityinfo = {} securityinfo['security_type'] = 'Portal' securityinfo['username'] = "username" securityinfo['password'] = "password" securityinfo['org_url'] = "https://yourportal.com/webadaptor" securityinfo['proxy_url'] = None
securityinfo['proxy_port'] = None securityinfo['referer_url'] = None securityinfo['token_url'] = None securityinfo['certificatefile'] = None securityinfo['keyfile'] = None securityinfo['client_id'] = None securityinfo['secret_id'] = None

token = securityhandlerhelper.securityhandlerhelper(securityinfo=securityinfo)

admin = arcrest.manageorg.Administration(securityHandler=token.securityhandler)

portal = admin.portals.portalSelf

json has to be correct format, logged into AGOL to then use "defaultBasemap" getter to download JSON and inject into portal

with open('path\to\basemapjson\basemap.json') as f: newbmap = json.load(f)

newbmap2 = json.dumps(newbmap)

pp = arcrest.manageorg.PortalParameters()

pp = arcrest.manageorg.PortalParameters()

pp.defaultBasemap = newbmap2

portal.update(pp)

print(portal.defaultBasemap)