Content Server 20.3 - unable to upload a document to a specific folder using the REST API
We are trying to create a new node in Content Server by uploading a file from a local source. We want to put the document in a specific Content Server folder that we created in the Enterprise Workspace.
We tried:
POST with application/x-www-form-urlencoded
- with body: {"file":"D:\\Temp\\project_26.docx","parent_id:":"31622","name":"project_26.docx","type":"144"}
- with body {"parent_id:":"31622","name":"project_26.docx","type":"144"} and parameter file
We got the following error:
{"error": "Error: File could not be found within the upload directory."}
We tried multipart/form-data with the following parts:
- parent_id
- type
- name
- file - binary data
We got the following error:
{"error":"Missing required parameter \u0027Parent ID\u0027"}
Questions:
- It is possible to create a node with a file uploaded from a local system?
- What is the upload directory? It's shared or private to the Content Server?
- Is there any configuration required in Content Server to enable this?
Comments
-
Typically with JavaScript one actually puts a "file" object. In postman one does not type the file as in a string but uses a file object. I don't know what you mean by a local file
JS would look something like
var params = { name: 'example', type: 144, parent_id: 123456 } var content = new File(['example'], 'example.txt', { type: 'text/plain' }) var formData = new FormData() formData.append('body', JSON.stringify(params)) formData.append('file', content) $.ajax({ method: 'POST', url: '.../api/v2/nodes', data: formData, contentType: false, processData: false, headers: { otcsticket: '...' } }).then(function (response) { console.log('success:', response) }, function (jqxhr) { console.log('failure:', jqxhr.responseJSON) })
a HTML file with some buttons so you can browse to a file where it takes you. This used to work
sorry did not test
CS cannot accept a file like in a UNC or a drive path it has to come via the webserver's temp or the upload directory both are temporary places where a file can be provided to the webserver.
the file I am giving comes from this thread
there should be other samples including postman screencaps in here many times people go wrong by doing a drive letter
0 -
Here is a better attempt at putting a file using POSTMAN.I use the file parameter and browse to a UNC share I have access
the code for JS hence becomes
var form = new FormData(); form.append("type", "144"); form.append("parent_id", "102893"); form.append("name", "Filename for CS"); form.append("file", fileInput.files[0], "///MYUNCSERVER/softwaredownloads/software/Useful/REST API Examples.postman_collection.json"); var settings = { "url": "http://restserver:8080/OTCS/cs.exe/api/v1/nodes", "method": "POST", "timeout": 0, "headers": { "otcsticket": "QiQP" }, "processData": false, "mimeType": "multipart/form-data", "contentType": false, "data": form }; $.ajax(settings).done(function (response) { console.log(response); });
CURL
curl --location --request POST 'http://resetserver:8080/OTCS/cs.exe/api/v1/nodes' \ --header 'otcsticket: QiQPcgfj73' \ --form 'type="144"' \ --form 'parent_id="102893"' \ --form 'name="Filename for CS"' \ --form 'file=@"///uncserver/softwaredownloads/software/Useful/REST API Examples.postman_collection.json"'
1
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 160 General Questions
- 149 Thrust Services
- 57 Developer Hackathon
- 37 Thrust Studio
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 33 eDOCS
- 190 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 10 XM Fax
- Follow Categories