1

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.

3
  • Have you seen the ArcREST package? Nearly 100% of REST API coverage with lots of things wrapped into handy functions github.com/Esri/ArcREST Jan 26, 2016 at 14:14
  • yes that's how I am generating the token...I did not find any documentation for addItem within the ArcREST package so I used it to build the URL's and am trying to do a conventional post as the documentation specifies..
    – risail
    Jan 26, 2016 at 14:16
  • I'm not really sure what you're asking, but a common parameter should be able to put into the payload if it is indeed common. However, the particular item being may have different requirements. You can see how I call addItem when uploading files (package types): github.com/arcpy/sample-gp-tools/blob/master/SharePackage2/…
    – KHibma
    Jan 26, 2016 at 14:26

1 Answer 1

0

I spoke with ESRI tech support and this is a defect with the API. At this time you can not add secure services to portal 10.3.1 with the API and have the password stored. It can only be done client side. They claim that this has been fixed in portal 10.4 which will be available in the next few weeks. They also do not have plans to fix this issue for 10.3.1.

After more testing the above statement is incorrect..the code above works the token that has to be passed is the portal token. I hard coded in a token and it worked.

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.