Is it possible to add a Portal content item from a secured service?

07-21-2017 07:26 AM
Occasional Contributor III

I've successfully used the Python API to add a non-secure map service from a non-federated ArcGIS Server site (10.2.2) to a Portal (10.5.1).  However if I turn security on for the map service then there doesn't seem to be an option in the API reference that allows me to specify credentials. It will still go ahead and add the service as a Portal content item but then when you try to load the layer into the Portal map viewer it prompts for the credentials (strangely the layers from the service are already loaded and drawn in the background before anything is entered in the credentials box).

Is there a way via the API to save the security credentials for the service within the content item in the same way that you can if you add the same service in manually?



0 Kudos
1 Reply
New Contributor II

I too have this question, while looking at my code to show in this post I noticed an error, I fix and now it is working.

gis = GIS(originPortal,portalAdminAcct,portalAdminPass)
token = gis._con.token

item_properties = {

"title":"TestAdd2", #the same title

"url":"<Secured Service URL>":,

"type":"Feature Service",
"description":"Test Me",
"serviceUsername":"<secured service username>",
"servicePassword":"<secured service password>",


gis.content.add(data="<Secured Service URL>",owner="<owner you choose>",item_properties=item_properties)

0 Kudos