Using the code below I am adding 100's of Map Services
to a portal instance. The script successfully runs and adds them however the services are secure so I would like portal to store the username
and passwords
. Using the ESRI API documentation I can see that within the [Item Info Parameters]
there are username
and password
parameters which is a common parameter. How do I call the common parameters and set them?
service_url = arcserver.list_services()
for each in service_url:
serv_name = each.split('/')[7]
temp_url = each.split('/')[0:7]
rest_end_pt = '/'.join(temp_url) + '/' + serv_name.replace('.', '/')
title = serv_name.replace('.MapServer', '')
tag = each.split('/')[6]
payload = {'token': sh.token, 'url': rest_end_pt, 'title': title, "type": "Map Service"}
post_url = admin.root + '/addItem'
print post_url
a = requests.post(post_url, data=payload)
print a
Ive tried passing the username and password in multiple variations:
payload = {'token': sh.token, 'url': rest_end_pt, 'title': title, "type": "Map Service", 'serviceUsername': 'xxx', 'servicePassword': 'xxx'}
Which results in a failure in the form of 400 response.
addItem
within theArcREST
package so I used it to build the URL's and am trying to do a conventional post as the documentation specifies..