Select to view content in your preferred language

Update AGOL Content Name and Share

1114
5
10-15-2021 04:19 AM
StuartMoore
Frequent Contributor

is it possible to change the title of a file thats stored in AGOL and share it with a group using AGOL Notebooks so that i can have it running as a task

thanks

Stu

0 Kudos
5 Replies
StuartMoore
Frequent Contributor

so i tried this to share my content

fc_item = search_for_batch_reports[0]
fc_item.share(groups=['5edd............e68'])

but all i get is this:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-61-44a9c5ed5fef> in <module>
      1 fc_item = search_for_batch_reports[0]
----> 2 fc_item.share(groups=['5edd............e68'])

TypeError: 'dict' object is not callable

 

0 Kudos
by Anonymous User
Not applicable

Hi Stuart, it appears your syntax is correct from what you've shown. See below for a working example. Is it possible your 'fc_item' variable isn't a valid item? What is 'search_for_batch_reports[0]'?

JoshCullen_1-1634588242537.png

 

Regarding changing the title of an item, see the below code. Also see the relevant documentation here (note: it appears the example given here is broken - you cannot pass description, title, etc. as arguments. They must be inside a keyvalue pair dictionary):  https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.update 

JoshCullen_3-1634589056947.png

 

LMK if you have any more questions.

Josh

 

StuartMoore
Frequent Contributor

thanks @Anonymous User i tried that but got a slightly different error, is it because i am trying to share a Survey123 word document with a group rather than feature

search_for_batch_reports = gis.content.search("H..............1")
print("Search result: ", search_for_batch_reports)

search_for_batch_reports.share(groups=['5edd............e68'])

 

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-1e3c6c4eb4e2> in <module>
----> 1 search_for_batch_reports.share(groups=['5e.............e68'])

AttributeError: 'list' object has no attribute 'share'
0 Kudos
StuartMoore
Frequent Contributor

just noticed that in your example you used 

 gis.content.get but when i use that it returns nothing but gis.content.search returns my file...

0 Kudos
StuartMoore
Frequent Contributor

got the sharing to work using this:

gis.content.share_items(items=search_for_batch_reports, groups=['5e................e68'])

 

0 Kudos