Select to view content in your preferred language

How to return derived out put from 'Share Package'

799
6
07-27-2022 04:47 PM
tsmith4517
Emerging Contributor

Hello,

I am curious to know how I might be able to return this output as a string. I am able to publish the tile package but, I am a bit confused on how to access this 'Derived Output'. I have tried "return publish_results" as well as "print(publish_results)" and got errors back. I will attach a link of the tool in question.  https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/share-package.htm#GUID-D54F5... 

 

Thank you in advance

0 Kudos
6 Replies
by Anonymous User
Not applicable

try assigning the method to a variable and then accessing the output attributes like this:

result = arcpy.management.SharePackage(r"C:\states.lpkx", "", "", 
                              "My Summary", "tag1, tag2", "My Credits", 
                              "MYGROUPS", "My Group")

print(result.publish_results) # or print(result['publish_results'])

 

0 Kudos
tsmith4517
Emerging Contributor

Jeff, Thank you for the response, unfortunately I am getting an error kicked back. I attached an image of my code and error message. Any ideas of what I am doing wrong?

0 Kudos
by Anonymous User
Not applicable

You could try

print(result)
#or
print(result['publish_results'])

or if you can look at the Results object in the debugger to see its structure.

0 Kudos
tsmith4517
Emerging Contributor

print(result) returned a Boolean and print(result['publish_results']) returned the same error above

 

0 Kudos
by Anonymous User
Not applicable

Seems that there is a disconnect in the documentation and the tool's derived output.  Looking at the result in the debugger, there isn't any published result. "JSON response containing the service URL and portal item ID of the web layer."

Screenshot 2022-07-29 054049.png

if you use getOutput(2) on the result object, it returns the item id:

msg2 = result.getOutput(2)
...
'1s71a2emadethisidupea250c748er'

which can be used to create/ reference the item in portal:

https://domain.com/portal/home/item.html?id=msg2

Maybe that is what they meant?  Wouldn't hurt to open a case with esri.

0 Kudos
KC
by
Regular Contributor

Hello, coming across this issue today, below are my findings.

I did a print(result.getOutput(0)), ... print(result.getOutput(2)) and it looks like this for me:

0: true
1: {"publishStatus":"completed","publishMessage":"","publishResult":{"type":"Map Service","serviceurl":"https://my.domain.org/server/rest/services/Hosted/mycachename/MapServer","serviceItemId":"123HostedTileLayerItemID4567890A","jobId":"123JobID4567890ABCDEFGHIJKLMNOPQR"}}
2: 123TilePackageItemID4567890ABCDE

I was after the Item IDs of the tile package and the published hosted layer, so this worked for me:

thisdict = json.loads(result.getOutput(1))
print("Tile Layer (hosted) Item ID on Portal: thisdict["publishResult"]["serviceItemId"])
print("Tile Package (tpkx) Item ID on Portal: result.getOutput(2))

0 Kudos