<?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: Handle Item Move to Folder Error in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/handle-item-move-to-folder-error/m-p/1545079#M10730</link>
    <description>&lt;P&gt;Thank you for posting your solution.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Oct 2024 05:50:09 GMT</pubDate>
    <dc:creator>AndresCastillo</dc:creator>
    <dc:date>2024-10-03T05:50:09Z</dc:date>
    <item>
      <title>Handle Item Move to Folder Error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/handle-item-move-to-folder-error/m-p/814848#M2633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attempting to move an item to a specific folder (using Python API, NOT Juypter). I don't see anything in the API to check if a folder exists. So according to the API:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;move&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;EM&gt;folder&lt;/EM&gt;, &lt;EM&gt;owner=None&lt;/EM&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;A href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#arcgis.gis.Item.move" title="Permalink to this definition"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline; "&gt;¶&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Moves this item to the folder with the given name.&lt;/P&gt;&lt;DIV&gt;&lt;TABLE border="1"&gt;&lt;TBODY valign="top"&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Argument&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;folder&lt;/TD&gt;&lt;TD&gt;Required string. The name of the folder to move the item to. Use ‘/’ for the root folder. For other folders, pass in the folder name as a string, or a dictionary containing the folder ID, such as the dictionary obtained from the folders property.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;owner&lt;/TD&gt;&lt;TD&gt;Optional string or Owner object. The name of the user to move to.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;TABLE frame="void" rules="none"&gt;&lt;TBODY valign="top"&gt;&lt;TR&gt;&lt;TH&gt;Returns:&lt;/TH&gt;&lt;TD&gt;A json object like the following: {“success”: true | false,&lt;BLOCKQUOTE&gt;&lt;DIV&gt;”itemId”: “&amp;lt;item id&amp;gt;”, “owner”: “&amp;lt;owner username&amp;gt;”, “folder”: “&amp;lt;folder id&amp;gt;”}&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out how to capture the return object.&amp;nbsp; I've wrapped it in a Try/Catch but that doesn't seem to work.&amp;nbsp; It always gets to the next line but I get the console message, Folder not found for given owner.&lt;/P&gt;&lt;P&gt;If&amp;nbsp;I do:&lt;/P&gt;&lt;P&gt;objMoved = myItem.move(folder="whatever")&lt;/P&gt;&lt;P&gt;objMoved is always None&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's the "best practice" way to get the results?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Oct 2019 13:54:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/handle-item-move-to-folder-error/m-p/814848#M2633</guid>
      <dc:creator>KarenRobine</dc:creator>
      <dc:date>2019-10-17T13:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Handle Item Move to Folder Error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/handle-item-move-to-folder-error/m-p/814849#M2634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following code solves my issue:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;objMoved = newmap.move(&lt;SPAN style="color: #aa4926;"&gt;folder&lt;/SPAN&gt;=configStore.folder)  &lt;SPAN style="color: #808080;"&gt;#folder not found for given owner message if it doesnt move it.
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(objMoved)
&lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;(objMoved &lt;SPAN style="color: #cc7832;"&gt;is None&lt;/SPAN&gt;) &lt;SPAN style="color: #cc7832;"&gt;or &lt;/SPAN&gt;\
        (objMoved &lt;SPAN style="color: #cc7832;"&gt;is not None and &lt;/SPAN&gt;&lt;SPAN style="color: #6a8759;"&gt;'success' &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;objMoved &lt;SPAN style="color: #cc7832;"&gt;and not &lt;/SPAN&gt;objMoved[&lt;SPAN style="color: #6a8759;"&gt;'success'&lt;/SPAN&gt;]):
    &lt;SPAN style="color: #8888c6;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #6a8759;"&gt;"we flunked moving the object"&lt;/SPAN&gt;)

    newmap.delete(&lt;SPAN style="color: #aa4926;"&gt;force&lt;/SPAN&gt;=&lt;SPAN style="color: #cc7832;"&gt;False, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;dry_run&lt;/SPAN&gt;=&lt;SPAN style="color: #cc7832;"&gt;False&lt;/SPAN&gt;)
    sys.exit(
        &lt;SPAN style="color: #6a8759;"&gt;"ERROR: Unable to move the item with ItemID {0} to the folder, {1}. "&lt;/SPAN&gt;.format(
            id&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;configStore.folder))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:36:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/handle-item-move-to-folder-error/m-p/814849#M2634</guid>
      <dc:creator>KarenRobine</dc:creator>
      <dc:date>2021-12-12T09:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Handle Item Move to Folder Error</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/handle-item-move-to-folder-error/m-p/1545079#M10730</link>
      <description>&lt;P&gt;Thank you for posting your solution.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 05:50:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/handle-item-move-to-folder-error/m-p/1545079#M10730</guid>
      <dc:creator>AndresCastillo</dc:creator>
      <dc:date>2024-10-03T05:50:09Z</dc:date>
    </item>
  </channel>
</rss>

