Select to view content in your preferred language

Arcpy Sharepackage standalone script

942
4
Jump to solution
01-14-2023 05:42 AM
Rahul_Pandia
New Contributor II

Hello,
I am not able to run Sharepackage tool from a standalone script.(unable to sign in to portal)

Basically, It is not able to connect to portal.Just to clarify I able to run this script as Model Builder.
Also I am able to connect to portal via arcgis pro.

Error: 

Processing .... Share Package :
Traceback (most recent call last):
File "e:\script\test.py", line 130, in <module>
arcpy.management.SharePackage(in_package=Maps_vtpk, username=_username, password=_password, summary=_summary_shrPk, tags=_tags_shrPk, credits=_credits, public=_public, groups=[], organization=_organization, publish_web_layer=_publish_web_layer, portal_folder=_portal_folder)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 12777, in SharePackage
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 12774, in SharePackage
retval = convertArcObjectToPythonObject(gp.SharePackage_management(*gp_fixargs((in_package, username, password, summary, tags, credits, public, groups, organization, publish_web_layer, portal_folder), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 002119: Must be connected and signed into the portal.
Failed to execute (SharePackage).

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Rahul_Pandia
New Contributor II

It turns out you need allow arcgis pro for offline usage
Then the Error vanishes

View solution in original post

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

in pro or modelbuilder you are connected to portal if you signed in

002119: Must be connected and signed into the portal.—ArcGIS Pro | Documentation

is explicit, so if you need to sign in, then there are tools in arcpy to do so 

SignInToPortal—ArcGIS Pro | Documentation

but not being a portal or enterprise person, you will have to experiment on your own


... sort of retired...
0 Kudos
Rahul_Pandia
New Contributor II

Yes... my understanding is in sync with yours
I had tried few combinations....but SignInToPortal has been disabled for standalone scripts(https://support.esri.com/en/technical-article/000021927)
but then there must be a way to call this tool 

0 Kudos
Rahul_Pandia
New Contributor II

It turns out you need allow arcgis pro for offline usage
Then the Error vanishes

0 Kudos
DanPatterson
MVP Esteemed Contributor

As indicated previously "in pro or modelbuilder you are connected to portal if you signed in..."


... sort of retired...
0 Kudos