<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add storymap to existing collection programmatically using python api in ArcGIS StoryMaps Questions</title>
    <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1387823#M4522</link>
    <description>&lt;P&gt;Love that! Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/538421"&gt;@ThePreatorian&lt;/a&gt;. Will get back to you if I have any further questions.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2024 01:30:01 GMT</pubDate>
    <dc:creator>atmosfairy</dc:creator>
    <dc:date>2024-02-28T01:30:01Z</dc:date>
    <item>
      <title>Add storymap to existing collection programmatically using python api</title>
      <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1381350#M4479</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have created a python tool that allows multiple users to create a storymap based on a template. I have manually grouped these together to create a collection. However, I would like to implement an instruction that will programatically add the newly created storymap to the collection.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have inspected the collection and all I can see is a dictionary of a single Collection-UI node. Is there a way to do this noting that I am using arcgis 2.2.0?&lt;/P&gt;&lt;P&gt;** UPDATE - I can access the json file and can see I need to add another resourceId node defining type&amp;nbsp; and specifying the item id of the portal item. So my question now is: how do I add a resourceId node to the json file?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 23:19:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1381350#M4479</guid>
      <dc:creator>atmosfairy</dc:creator>
      <dc:date>2024-02-12T23:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add storymap to existing collection programmatically using python api</title>
      <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1381563#M4482</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/745726"&gt;@atmosfairy&lt;/a&gt;&amp;nbsp; You have made a lot of progress.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Unfortunately the python API does not currently support StoryMap Collections. But that will be fixed with the April 2.3.0 release.&lt;BR /&gt;&lt;BR /&gt;You are on the right track. We will need to update the json file for the collection programmatically. And possibly do a few things to the Collection metadata depending on your use case. I just have a couple questions in order to understand the workflow better:&lt;BR /&gt;1. Are you creating a brand new Collections, or planning to add to an existing Collection?&lt;BR /&gt;2. Do you plan to verify the Collection after running your script before publishing the changes?&lt;BR /&gt;&lt;BR /&gt;In the end you will probably need to use a combination of the the following methods/packages to get this working:&lt;BR /&gt;&lt;BR /&gt;ResourceManager.add&amp;nbsp; (esri python api)&lt;BR /&gt;Item.update (esri python api)&lt;BR /&gt;json (built in python package)&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 14:41:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1381563#M4482</guid>
      <dc:creator>ThePreatorian</dc:creator>
      <dc:date>2024-02-13T14:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Add storymap to existing collection programmatically using python api</title>
      <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1383926#M4496</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/538421"&gt;@ThePreatorian&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;In 99% of cases, I will be adding new storymaps to an existing collection; however, there may be the need to create a new collection from time-to-time.&lt;/P&gt;&lt;P&gt;Haven't thought about verifying the Collection after running script, but before publishing changes - is this the recommended workflow?&lt;/P&gt;&lt;P&gt;And thanks for getting back to me - good to know that this functionality is just around the corner&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 00:42:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1383926#M4496</guid>
      <dc:creator>atmosfairy</dc:creator>
      <dc:date>2024-02-19T00:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Add storymap to existing collection programmatically using python api</title>
      <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1384386#M4499</link>
      <description>&lt;P&gt;We always recommend QA on items generated programmatically.&lt;BR /&gt;Here is some code to get you started. Updating the itemKeywords will be important in order to point your story to the newly created draft. You might need to modify as needed&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Get collection Item
target_collection = Item(itemid="COLLECTION_ITEM_ID")
target_collection_json = draft_data = draft_data = 
#This draft will be modified with new information
draft_data = target_collection.resources.get("published_data.json", try_json=True)
#Generate a new draft_filename
draft_file_name = f"draft_{unix_timestamp}.json"
#Get the node that will get the new items
root_id = draft_data['root']
ui_child_id = draft_data['nodes']['root_id']['children'][0]
collention_ui_node = draft_data['nodes']['ui_child_id']

for storyID in storymap_list:
  #generate new resourceID
  generated_resource_id = f"r-{uuid4()[:6]}"
  #Add StoryMap Id as new Item
  draft_data['resources'][generated_resource_id] = {
   "type": "portal-item",
   "data": {
   "itemId": storyID
   }
  }
  #Update Itemrefs
 collection_ui_node['data'['items'].append({"resourceId":generated_resource_id})

#Remove existing Keywords
keywords = target_collection.typeKeywords
if 'smstatuspublished'in keywords:
 keywords.pop('smstatuspublished')
if 'smstatusunpublishedchanges' in keywords:
 keywords.pop('smstatusunpublishedchanges')

#Append Editor App, unpublished and Draft pointer keyword
keywords.append('smeditorapp:python')
keywords.append('unpublished')
keywords.append(f'smdraftresourceid:{draft_file_name}.json')

#update keywords on the item
target_collection.update(item_properties={"typeKeywords":keywords})
#add the new Draft as a resource
target_collection.resources.add(file_name=draft_file_name, text=json.dumps(data, indent=4))

  
  

  
 

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 15:33:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1384386#M4499</guid>
      <dc:creator>ThePreatorian</dc:creator>
      <dc:date>2024-02-20T15:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Add storymap to existing collection programmatically using python api</title>
      <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1387823#M4522</link>
      <description>&lt;P&gt;Love that! Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/538421"&gt;@ThePreatorian&lt;/a&gt;. Will get back to you if I have any further questions.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 01:30:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1387823#M4522</guid>
      <dc:creator>atmosfairy</dc:creator>
      <dc:date>2024-02-28T01:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Add storymap to existing collection programmatically using python api</title>
      <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1387987#M4523</link>
      <description>&lt;P&gt;Noticed A couple of naming/syntax issues with the previous code. Cleaned up a bit here:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Get collection Item
target_collection = Item(itemid="COLLECTION_ITEM_ID")
#This draft will be modified with new information
draft_data = target_collection.resources.get("published_data.json", try_json=True)
#Generate a new draft_filename
draft_file_name = f"draft_{unix_timestamp}.json"
#Get the node that will get the new items
root_id = draft_data['root']
ui_child_id = draft_data['nodes']['root_id']['children'][0]
collention_ui_node = draft_data['nodes']['ui_child_id']

for storyID in storymap_list:
  #generate new resourceID
  generated_resource_id = f"r-{uuid4()[:6]}"
  #Add StoryMap Id as new Item
  draft_data['resources'][generated_resource_id] = {
   "type": "portal-item",
   "data": {
   "itemId": storyID
   }
  }
  #Update Itemrefs
 collection_ui_node['data'['items'].append({"resourceId":generated_resource_id})

#Remove existing Keywords
keywords = target_collection.typeKeywords
if 'smstatuspublished'in keywords:
 keywords.pop('smstatuspublished')
if 'smstatusunpublishedchanges' in keywords:
 keywords.pop('smstatusunpublishedchanges')

#Append Editor App, unpublished and Draft pointer keyword
keywords.append('smeditorapp:python')
keywords.append('unpublished')
keywords.append(f'smdraftresourceid:{draft_file_name}.json')

#update keywords on the item
target_collection.update(item_properties={"typeKeywords":keywords})
#add the new Draft as a resource
target_collection.resources.add(file_name=draft_file_name, text=json.dumps(draft_data, indent=4))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 28 Feb 2024 13:10:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1387987#M4523</guid>
      <dc:creator>ThePreatorian</dc:creator>
      <dc:date>2024-02-28T13:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Add storymap to existing collection programmatically using python api</title>
      <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1387989#M4524</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/538421"&gt;@ThePreatorian&lt;/a&gt;&amp;nbsp;that is helpful advice to QA programmatically created content. Do you know where one can find a definition of the StoryMap model to check against, such as what keywords are required, optional, etc.?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 13:18:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1387989#M4524</guid>
      <dc:creator>PeterKnoop</dc:creator>
      <dc:date>2024-02-28T13:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Add storymap to existing collection programmatically using python api</title>
      <link>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1388129#M4525</link>
      <description>&lt;P&gt;At this time, we have not published developer documentation for ArcGIS StoryMaps. However, you can use the&amp;nbsp;&lt;STRONG&gt;StoryMap&lt;/STRONG&gt;&amp;nbsp;,&amp;nbsp;&lt;STRONG&gt;Briefing&lt;/STRONG&gt;&amp;nbsp;, and&amp;nbsp;&lt;STRONG&gt;Collection&lt;/STRONG&gt;&amp;nbsp;classes in the Python API to create ArcGIS StoryMap items. These classes manage keywords, and we do not recommend editing them manually. If you need to query keywords for your scripts, you can use the&amp;nbsp;&lt;STRONG&gt;{Class}._item.typeKeywords&lt;/STRONG&gt;&amp;nbsp;property.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note the above advice of manually manipulating everything is only applicable until Python v2.3.0 is released around April 2024. After that release,&amp;nbsp;&lt;EM&gt;Collections&lt;/EM&gt;&amp;nbsp;and&amp;nbsp;&lt;EM&gt;Briefings&lt;/EM&gt;&amp;nbsp;will be supported in the API, so the recommended way to manipulate the Collection would be to use the class-specific methods.&lt;/P&gt;&lt;P&gt;If you have any further questions or need more information, feel free to ask!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 16:27:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-storymaps-questions/add-storymap-to-existing-collection/m-p/1388129#M4525</guid>
      <dc:creator>ThePreatorian</dc:creator>
      <dc:date>2024-02-28T16:27:06Z</dc:date>
    </item>
  </channel>
</rss>

