Help on REST API to upload new document to folder

cancel
Showing results for 
Search instead for 
Did you mean: 
billwyuan
Member II

Help on REST API to upload new document to folder

Upload a text document to a folder in Alfresco seems not working using Rest API. I have a site named R02, under documentLibrary has a folder bank1. I am using Postman rest client tool.

POST: http://76eiss.trial.alfresco.com/alfresco/service/api/upload?alf_ticket=TICKET_a314df3eb2e0ac986b26e...

Header: Authorization: [{"key":"Authorization","value":"Basic YmlsbHd5dWFuQHlhaG9vLmNvbToxMjM0eXVhbg==","description":""}] 

Request body

{
"filedata":"any text",
"filename": "test1.txt"
"description": "example"
"siteid":"r02",
"containerid":"documentlibrary" ,
'uploaddirectory': 'bank1'

also tried:

{
"filedata": "textxxxxxl",
"filename": "test1.txt",
"description": "example",
"siteid": "r02",
"containerid": "508440fc-1578-45a5-b4f7-87eb5ea6f40a"

}

and 

{
"filedata": "@test.txt",
"filename": "abc.text",
"siteid": "r02",
"containerid": "workspace:\/\/SpacesStore\/99c6f662-242f-4917-85bb-ae5a9b8454e8"

}

In response, it always return 502 bad gateway. I also tried a community edition 5.0.d. Not success.  Does anyone see the problem I have?

thank you very much!

Bill

1 Reply
marktielemans
Active Member II

Re: Help on REST API to upload new document to folder

The upload webscript expects HTML form data. Have you tried specifying the Content-Type as application/x-www-form-urlencoded?