Hi,
I'm doing some tests with Rest Api in Python.
Following the rest Api Explorer (https://api-explorer.alfresco.com/api-explorer/#!/nodes/createNode) and this link: https://docs.alfresco.com/6.2/concepts/dev-api-by-language-alf-rest-upload-file.html
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.
Here's a small example:
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()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.
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 ?
Thanks for help!