publish content directly to a named folder

823
4
Jump to solution
10-10-2020 09:22 PM
IanHamilton2
New Contributor III

Hi , I haven't been able to find any help on publishing content to a named folder on AGOL/Portal using the python API.

The example I have created in the user home folder and then gives code to move the content, creating a folder in the process.

Is this the preferred method?

Or should I be able to publish things directly to a specific folder?

Thanks.

Ian

1 Solution

Accepted Solutions
MehdiPira1
Esri Contributor

Hi Ian Hamilton‌,

The Publish method in ArcGIS API for Python doesn't have any parameters to specify a named folder when publishing.

Publish items 

However, the Add method in the Content Manager gives you this option to add your item to a named folder then publish it from there.

add(item_properties, data=None, thumbnail=None, metadata=None, owner=None, folder=None, item_id=None)

Add items 

you also have the option to move items to an already created folder using move(folder, owner=None)

Move items 

View solution in original post

4 Replies
MehdiPira1
Esri Contributor

Hi Ian Hamilton‌,

The Publish method in ArcGIS API for Python doesn't have any parameters to specify a named folder when publishing.

Publish items 

However, the Add method in the Content Manager gives you this option to add your item to a named folder then publish it from there.

add(item_properties, data=None, thumbnail=None, metadata=None, owner=None, folder=None, item_id=None)

Add items 

you also have the option to move items to an already created folder using move(folder, owner=None)

Move items 

MehdiPira1
Esri Contributor

Hi Ian Hamilton‌,

Would you please mark it as answered if that answered your question?

Thank you.

0 Kudos
JackFanZhang
New Contributor III

It would be better if ESRI can enhance the publish function to include an option for specified name AGOL/Portal folder. Seem that's the only missing link in the publish function. The option to specify the output ArcGIS Server folder is available, why not adding the AGOL/Portal folder.

0 Kudos
BrianWilson7
Regular Contributor

If you use the workflow to publish using arcpy "UploadServiceDefinition" you can specify both a portalFolder and a serverFolder in the service definition.

However, depending on what you are publishing sometimes it will just ignore the portalFolder setting.

If you do the upload and then follow it immediately with a "move" the results are more reliable.

Also note that the type of service will determine where it gets published on the server, sometimes it is forced into "Hosted" folder no matter what you give it in serverFolder and if you specify serverFolder="Hosted" for some services it will ignore that and put the service at "/" (root).

Hope this helps someone.

 

 

0 Kudos