How can I change the serviceUsername and servicePassword associated with an online feature item that is based on a secure ArcGIS server REST endpoint?
I set the credentials when I create the item:
item_properties={ 'title': dp_flc['title'], 'snippet': dp['summary'], 'description': dp_flc['description'], 'tags': dp['tags'].split(','), 'type': 'Feature Service', 'url': service_url, 'serviceUsername': service_user_name, 'servicePassword': service_pw } gis_content_item = AppInfo.gis_agol.content.add(item_properties=item_properties, data=service_url, thumbnail=dp_flc['thumbnail'], folder=AppInfo.content_folder)
But when I include serviceUsername and servicePassword on an update request I get an 'code 500- Error generating token' message. The values username and password values appear to be correct. When I remove the two lines the update works as expected. According to the documentation the 2 parameters are supposed to be supported on update.
# Apply the changes to the feature layer collection agol_token = row.util.common.get_agol_token (AppInfo.agol_connect_user_name, row.util.stash_credentials.get_password(AppInfo.agol_connect_user_name, 'AGOL')) params = {'text': json.dumps(update_spec), 'title': dp_flc['title'], 'url': dp_rest_service['url'], 'serviceUsername': AppInfo.ags_connect_consumer_user_name, 'servicePassword': row.util.stash_credentials.get_password(AppInfo.ags_connect_consumer_user_name, 'AGS_CONSUMER'), 'f': 'json', 'token': agol_token} url = AppInfo.agol_connect_host_name + '/sharing/rest/content/users/' + AppInfo.agol_connect_user_name + '/' + gis_content_item['ownerFolder'] + '/items/' + gis_content_item.id + '/update' req = urllib.request.Request(url, urlencode(params).encode('utf-8')) response = urllib.request.urlopen(req) data = json.load(response) if 'error' in data: msg = "Feature layer collection update failed: " + str(data['error']) logger.error (msg) raise Exception(msg)
Solved! Go to Solution.
I found that I could update the credentials by sending a JSON update request with just these parameters:
url: https://rowhwg.erc.uic.edu/arcgis/rest/services/ROW/ERC_FW/FeatureServer serviceUsername: xxxxx servicePassword: yyyyy id: 6f9366cdd59748adb6e30e251fab7afa folderId: 04549141bb0f49d58b7f3fb50d5d71d5
It seems that if fails when certain other parameters are included (I didn't take the time to figure out which ones).
I found that I could update the credentials by sending a JSON update request with just these parameters:
url: https://rowhwg.erc.uic.edu/arcgis/rest/services/ROW/ERC_FW/FeatureServer serviceUsername: xxxxx servicePassword: yyyyy id: 6f9366cdd59748adb6e30e251fab7afa folderId: 04549141bb0f49d58b7f3fb50d5d71d5
It seems that if fails when certain other parameters are included (I didn't take the time to figure out which ones).