<?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: How to move a file with Netapp Ontap API? in ONTAP Rest API Discussions</title>
    <link>https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/How-to-move-a-file-with-Netapp-Ontap-API/m-p/447842#M585</link>
    <description>&lt;P&gt;From Python &lt;SPAN&gt;&lt;A href="https://pypi.org/project/netapp-ontap/" target="_blank" rel="noopener"&gt;netapp-ontap&lt;/A&gt; library which calls the REST API.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;"/Move" moves files between flex volumes? I don't need to do that, I just need to move files&amp;nbsp; within the same volume.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The docs say you can do this with the REST API like this to move /alice/bob/bb.txt to /alice/bob/charlie/bb.txt&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl -k --request PATCH \
  --url https://server.domain/api/storage/volumes/7da9eb81-6daa-4323-9eab-7bbce73da0f2/files/%2Falice%2Fbob%2Fbb.txt \
  --header 'Accept: application/json' \
  --header 'Authorization: Basic ******************' \
  --header 'User-Agent: httpyac' \
  --data '{
    "path" : "/alice/bob/charlie/bb.txt" 
}'&lt;/LI-CODE&gt;&lt;P&gt;This works.&lt;BR /&gt;&lt;BR /&gt;And there is an example in the docs, and the comments within the netapp python library that tells you to do this from python like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from netapp_ontap import HostConnection
from netapp_ontap.resources import FileInfo

with HostConnection("&amp;lt;mgmt-ip&amp;gt;", username="admin", password="password", verify=False):
    resource = FileInfo(
        "7da9eb81-6daa-4323-9eab-7bbce73da0f2", path="alice/bob/bb.txt"
    )
    resource.path = "alice/bob/charlie.txt"
    resource.patch()&lt;/LI-CODE&gt;&lt;P&gt;BUT this fails with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Caused by HTTPError('500 Server Error: Internal Server Error for url: https://server.domain:443/api/storage/volumes/7da9eb81-6daa-4323-9eab-7bbce73da0f2/files/%2Falice%2Fbob'): Failed to rename "/alice/bob" to 
"/alice/bob/charlie". Reason: Invalid argument&lt;/LI-CODE&gt;&lt;P&gt;The library correctly detects that path has changed and makes the body of the REST API request, but it fails to append the filename to the URL and thus is trying to rename the directory containing the file, rather than the file itself.&lt;BR /&gt;&lt;BR /&gt;By the way, in the docs the import also should read&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from netapp_ontap.host_connection import HostConnection&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I think this is a bug in the&amp;nbsp;&lt;SPAN&gt;netapp-ontap Python Library&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Sep 2023 13:34:35 GMT</pubDate>
    <dc:creator>brianrussell</dc:creator>
    <dc:date>2023-09-25T13:34:35Z</dc:date>
    <item>
      <title>How to move a file with Netapp Ontap API?</title>
      <link>https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/How-to-move-a-file-with-Netapp-Ontap-API/m-p/447811#M583</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;I can't see from the docs how to move a file using the Python Netapp API.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would have thought:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;resources = FileInfo.get_collection(volume, path)
resource = next(resources)
resource.path = '/new/path'
resource.patch(hydrate=True)&lt;/LI-CODE&gt;&lt;P&gt;would have worked but sadly no.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's the correct procedure?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 09:44:51 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/How-to-move-a-file-with-Netapp-Ontap-API/m-p/447811#M583</guid>
      <dc:creator>brianrussell</dc:creator>
      <dc:date>2025-06-04T09:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to move a file with Netapp Ontap API?</title>
      <link>https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/How-to-move-a-file-with-Netapp-Ontap-API/m-p/447839#M584</link>
      <description>&lt;P&gt;I guess, you mean using REST API ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you tried the steps as mentioned here.&lt;/P&gt;&lt;P&gt;&lt;A href="https://library.netapp.com/ecmdocs/ECMLP2884819/html/resources/file_move.html" target="_blank"&gt;netapp_ontap.resources.file_move API documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 12:35:43 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/How-to-move-a-file-with-Netapp-Ontap-API/m-p/447839#M584</guid>
      <dc:creator>Ontapforrum</dc:creator>
      <dc:date>2023-09-25T12:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to move a file with Netapp Ontap API?</title>
      <link>https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/How-to-move-a-file-with-Netapp-Ontap-API/m-p/447842#M585</link>
      <description>&lt;P&gt;From Python &lt;SPAN&gt;&lt;A href="https://pypi.org/project/netapp-ontap/" target="_blank" rel="noopener"&gt;netapp-ontap&lt;/A&gt; library which calls the REST API.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;"/Move" moves files between flex volumes? I don't need to do that, I just need to move files&amp;nbsp; within the same volume.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The docs say you can do this with the REST API like this to move /alice/bob/bb.txt to /alice/bob/charlie/bb.txt&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl -k --request PATCH \
  --url https://server.domain/api/storage/volumes/7da9eb81-6daa-4323-9eab-7bbce73da0f2/files/%2Falice%2Fbob%2Fbb.txt \
  --header 'Accept: application/json' \
  --header 'Authorization: Basic ******************' \
  --header 'User-Agent: httpyac' \
  --data '{
    "path" : "/alice/bob/charlie/bb.txt" 
}'&lt;/LI-CODE&gt;&lt;P&gt;This works.&lt;BR /&gt;&lt;BR /&gt;And there is an example in the docs, and the comments within the netapp python library that tells you to do this from python like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from netapp_ontap import HostConnection
from netapp_ontap.resources import FileInfo

with HostConnection("&amp;lt;mgmt-ip&amp;gt;", username="admin", password="password", verify=False):
    resource = FileInfo(
        "7da9eb81-6daa-4323-9eab-7bbce73da0f2", path="alice/bob/bb.txt"
    )
    resource.path = "alice/bob/charlie.txt"
    resource.patch()&lt;/LI-CODE&gt;&lt;P&gt;BUT this fails with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Caused by HTTPError('500 Server Error: Internal Server Error for url: https://server.domain:443/api/storage/volumes/7da9eb81-6daa-4323-9eab-7bbce73da0f2/files/%2Falice%2Fbob'): Failed to rename "/alice/bob" to 
"/alice/bob/charlie". Reason: Invalid argument&lt;/LI-CODE&gt;&lt;P&gt;The library correctly detects that path has changed and makes the body of the REST API request, but it fails to append the filename to the URL and thus is trying to rename the directory containing the file, rather than the file itself.&lt;BR /&gt;&lt;BR /&gt;By the way, in the docs the import also should read&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from netapp_ontap.host_connection import HostConnection&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I think this is a bug in the&amp;nbsp;&lt;SPAN&gt;netapp-ontap Python Library&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 13:34:35 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Rest-API-Discussions/How-to-move-a-file-with-Netapp-Ontap-API/m-p/447842#M585</guid>
      <dc:creator>brianrussell</dc:creator>
      <dc:date>2023-09-25T13:34:35Z</dc:date>
    </item>
  </channel>
</rss>

