HOW TO
When there are a lot of services added to ArcGIS Enterprise with stored credentials, and those credentials get updates, it could be very time-consuming to update them manually.
The below script automates updating the credentials by finding the items added to Portal for ArcGIS with stored credentials, and updating the credentials to the desired ones.
from arcgis.gis import GIS
gis = GIS("https://dns.esri.com/portal", "username", "password")
token = gis._con.token
content = gis.content.search(query="",max_items=10000)
def updateStoredCredentials(content):
for item in content:
if 'sourceUrl' in item:
item = gis.content.get(item.id)
properties = {"url":item['sourceUrl'],
"serviceUsername":"updatedusername",
"servicePassword":"updatedpassword",
"token":token,
}
item.update(item_properties=properties)
print(f"Successfully updated {item}")
updateStoredCredentials(content)
Article ID: 000032506
Get help from ArcGIS experts
Download the Esri Support App