<?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 Rest Api: Creating node with &amp;quot;overwrite&amp;quot; option doesn't update properties... in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101826#M29186</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm doing some tests with Rest Api in Python.&lt;BR /&gt;Following the rest Api Explorer (&lt;A href="https://api-explorer.alfresco.com/api-explorer/#!/nodes/createNode" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api-explorer.alfresco.com/api-explorer/#!/nodes/createNode&lt;/A&gt;) and this link: &lt;A href="https://docs.alfresco.com/6.2/concepts/dev-api-by-language-alf-rest-upload-file.html" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.alfresco.com/6.2/concepts/dev-api-by-language-alf-rest-upload-file.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I found the way to create node, uploading file with correct properties (working also with custom type and custom properties) using multipart/form-data in python with the "requests" library.&lt;/P&gt;&lt;P&gt;Here's a small example:&lt;/P&gt;&lt;PRE&gt;import os
import requests
from requests.auth import HTTPBasicAuth

USER = "username"
PASSWD = "password"


def upload_file():
    thisfolder = os.path.dirname(os.path.abspath(__file__))
    docfile = os.path.join(thisfolder, 'picture.jpg')
    node_id = "4efc2abb-e12c-4995-b2e4-f2ff5ee022ae"  # SAS uuid
    opUrl = 'nodes/%s/children' % node_id
    with open(docfile, 'rb') as file:
        files = {'filedata': file}
        createURL = 'http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/%s' % opUrl
        data = {
            "name": "picture.jpg",
            "nodeType": "cm:content",
            "overwrite": "true",
            "cm:title": "My Picture",
            "cm:description": "This is my picture",
        }
        response = requests.post(createURL, data=data, files=files, auth=HTTPBasicAuth(USER, PASSWD) )
        print(response)
        print(response.json)
        print(response.text)
        print(response.headers)


if __name__ == "__main__":
    upload_file()&lt;/PRE&gt;&lt;P&gt;My question concerns the "overwrite" option, it's incrementing the version when doing upload with the same "name", so i can change my file and version number is updated.&lt;/P&gt;&lt;P&gt;But "properties" (cm:title, cm:description,...) are never updated... so the overwrite option seems not concerning the "properties" but only the data... Very annoying when using custom properties or if i just want to update title or description. Is this a bug ? Am i missing an option ?&lt;BR /&gt;Thanks for help!&lt;/P&gt;</description>
    <pubDate>Mon, 23 Mar 2020 08:21:31 GMT</pubDate>
    <dc:creator>Maxx</dc:creator>
    <dc:date>2020-03-23T08:21:31Z</dc:date>
    <item>
      <title>Rest Api: Creating node with "overwrite" option doesn't update properties...</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101826#M29186</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm doing some tests with Rest Api in Python.&lt;BR /&gt;Following the rest Api Explorer (&lt;A href="https://api-explorer.alfresco.com/api-explorer/#!/nodes/createNode" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api-explorer.alfresco.com/api-explorer/#!/nodes/createNode&lt;/A&gt;) and this link: &lt;A href="https://docs.alfresco.com/6.2/concepts/dev-api-by-language-alf-rest-upload-file.html" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.alfresco.com/6.2/concepts/dev-api-by-language-alf-rest-upload-file.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I found the way to create node, uploading file with correct properties (working also with custom type and custom properties) using multipart/form-data in python with the "requests" library.&lt;/P&gt;&lt;P&gt;Here's a small example:&lt;/P&gt;&lt;PRE&gt;import os
import requests
from requests.auth import HTTPBasicAuth

USER = "username"
PASSWD = "password"


def upload_file():
    thisfolder = os.path.dirname(os.path.abspath(__file__))
    docfile = os.path.join(thisfolder, 'picture.jpg')
    node_id = "4efc2abb-e12c-4995-b2e4-f2ff5ee022ae"  # SAS uuid
    opUrl = 'nodes/%s/children' % node_id
    with open(docfile, 'rb') as file:
        files = {'filedata': file}
        createURL = 'http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/%s' % opUrl
        data = {
            "name": "picture.jpg",
            "nodeType": "cm:content",
            "overwrite": "true",
            "cm:title": "My Picture",
            "cm:description": "This is my picture",
        }
        response = requests.post(createURL, data=data, files=files, auth=HTTPBasicAuth(USER, PASSWD) )
        print(response)
        print(response.json)
        print(response.text)
        print(response.headers)


if __name__ == "__main__":
    upload_file()&lt;/PRE&gt;&lt;P&gt;My question concerns the "overwrite" option, it's incrementing the version when doing upload with the same "name", so i can change my file and version number is updated.&lt;/P&gt;&lt;P&gt;But "properties" (cm:title, cm:description,...) are never updated... so the overwrite option seems not concerning the "properties" but only the data... Very annoying when using custom properties or if i just want to update title or description. Is this a bug ? Am i missing an option ?&lt;BR /&gt;Thanks for help!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 08:21:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101826#M29186</guid>
      <dc:creator>Maxx</dc:creator>
      <dc:date>2020-03-23T08:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rest Api: Creating node with "overwrite" option doesn't update properties...</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101827#M29187</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the suggestion. Yes, unfortunately, that does seem to be the case at the moment. See for example:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Alfresco/alfresco-remote-api/blob/master/src/main/java/org/alfresco/rest/api/impl/NodesImpl.java#L3014" target="_blank" rel="noopener nofollow noreferrer"&gt;https://github.com/Alfresco/alfresco-remote-api/blob/master/src/main/java/org/alfresco/rest/api/impl/NodesImpl.java#L3014&lt;/A&gt;&amp;nbsp;(and surrounding code).&lt;/P&gt;&lt;P&gt;If I'm undertanding you correctly you would like to use multi-part/form data to not only create a new file node (with content &amp;amp; properties) but also update the same file in a similar way. I think your suggestion would be to use POST with "overwrite" flag.&lt;/P&gt;&lt;P&gt;Alternatively, it could be done with PUT&amp;nbsp; in the same way if we implemented and extended &lt;A href="https://issues.alfresco.com/jira/browse/REPO-146" target="_blank" rel="noopener nofollow noreferrer"&gt;https://issues.alfresco.com/jira/browse/REPO-146&lt;/A&gt;&amp;nbsp; idea to enable update of content &amp;amp; properties as a single request. The difference would be using "PUT" (with known node id) instead of "POST with overwrite" (with known node name).&lt;/P&gt;&lt;P&gt;I suggest you raise a new enhancement request in JIRA or update REPO-146 with more info if that might help. You could also provide a contribution with tests (and updates to the REST API Explorer).&lt;/P&gt;&lt;P&gt;In the meantime, can you make two calls ?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 17:52:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101827#M29187</guid>
      <dc:creator>janv</dc:creator>
      <dc:date>2020-03-26T17:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rest Api: Creating node with "overwrite" option doesn't update properties...</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101828#M29188</link>
      <description>&lt;BLOCKQUOTE&gt;Hi Jan,&lt;BR /&gt;&lt;BR /&gt;Thanks for your answer.&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/50997"&gt;@janv&lt;/A&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;If I'm undertanding you correctly you would like to use multi-part/form data to not only create a new file node (with content &amp;amp; properties) but also update the same file in a similar way. I think your suggestion would be to use POST with "overwrite" flag.&lt;/P&gt;&lt;P&gt;Alternatively, it could be done with PUT&amp;nbsp; in the same way if we implemented and extended &lt;A href="https://issues.alfresco.com/jira/browse/REPO-146" target="_blank" rel="noopener nofollow noreferrer"&gt;https://issues.alfresco.com/jira/browse/REPO-146&lt;/A&gt;&amp;nbsp; idea to enable update of content &amp;amp; properties as a single request. The difference would be using "PUT" (with known node id) instead of "POST with overwrite" (with known node name).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;Indeed, i could use "PUT", but "PUT" needs an existing node... In my case, using the POST with the "overwrite" flag allows me not to check if node already exists... so i could create or update existing node with the same api call. It seems logical to me that overwrite option allows to update properties...&lt;BR /&gt;In the case of using PUT, i've first to do a POST without "overwrite", catching errors and in case of 409 error, searching for the node_id then doing a PUT to update content and properties...&lt;BR /&gt;&lt;BR /&gt;I'm just a user, i do not feel comfortable with Java so do not feel able to provide contribution... just providing an idea for an eventual enhancement.&lt;BR /&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 30 Mar 2020 07:29:53 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101828#M29188</guid>
      <dc:creator>Maxx</dc:creator>
      <dc:date>2020-03-30T07:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rest Api: Creating node with "overwrite" option doesn't update properties...</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101829#M29189</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can anyone help me with this issue.&lt;/P&gt;&lt;P&gt;I am not able to use the "overwrite" flag in my post request. when i have that flag i am getting the following error,&lt;/P&gt;&lt;P&gt;Could not read content from HTTP request body: Unrecognized field \"overwrite\" (class org.alfresco.rest.api.model.Node)&lt;/P&gt;&lt;P&gt;I am using alfresco 6.2.2&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 18:02:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101829#M29189</guid>
      <dc:creator>udaikumar26</dc:creator>
      <dc:date>2021-03-19T18:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rest Api: Creating node with "overwrite" option doesn't update properties...</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101830#M29190</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/83246"&gt;@udaikumar26&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're updating an existing node I think you should be using PUT instead of POST? See &lt;A href="https://api-explorer.alfresco.com/api-explorer/#/nodes/updateNode" target="_self" rel="nofollow noopener noreferrer"&gt;https://api-explorer.alfresco.com/api-explorer/#/nodes/updateNode&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 13:41:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/rest-api-creating-node-with-quot-overwrite-quot-option-doesn-t/m-p/101830#M29190</guid>
      <dc:creator>EddieMay</dc:creator>
      <dc:date>2021-03-22T13:41:59Z</dc:date>
    </item>
  </channel>
</rss>

