Create Documents by Parent Folder ID
POST /ws/rest/service/v1/dm/document/create/<parent_node_id>
Purpose
Add documents (files) to a particular folder using the folder node id. It also supports adding revisions to an existing document.
Request Format
Send an API request in the following format:
https://<host>:<port>/ws/rest/service/v1/dm/document/create/<parent_node_id>
data: [ {"Name":"<value>",
"docTitle":"<value>",
"revNo":"<value>",
"issueDate":"<value>"
}]
Path Parameter
Specify the following path parameter:
Request Parameter | Required? | Data Type | Description |
---|---|---|---|
parent_folder_id | Yes | Integer | The ID of the parent folder's node where the documents will be created. |
Use the Get Folders or Documents Metadata by Path REST Service to get the node_id value for the folder.
Request Parameters
This a multi-part request and all parameters must be listed before all file parts in the following order:
Request Parameter | Required? | Data Type | Description |
---|---|---|---|
projectnumber | No | String | The project associated with the document. Not required for company level. If the projectnumber is not specified, the document is created in the Company Workspace. If the parent folder Id is not in the Company Workspace, the document will not be visible even in Company Workspace. |
dorevise | No | String | Indicates whether to revise the file using the same file name. Valid values include: "yes", and "no" (default). |
data | Yes | JSON String | List of field and values for the Document Attribute Form. |
Name | Yes | String | Name of the document to be created. |
Response Format
A JSON object is returned in the following format.
{
"data": [],
"message": [],
"status": <REST status code value>
}
Sample Request
To create a document "ProjectDetails.doc" in the"/Project Documents/Service docs" folder with node ID 6561, send the API request in the following format:
http://<host>:<port>/ws/rest/service/v1/dm/document/create/6561
[ {"fileName":"ProjectDetails.doc",
"docTitle":"project details",
"revNo":"1",
"issueDate":"06/01/2016",
<any additional document attribute form properties, excluding creation date and owner> }
]
Notes:
- Except for the creation date and owner, you can add any additional Document Attribute Form properties as key value pairs in the preceding JSON.
- This call only updates the elements visible in the Upload window, such as Document Title, Revision No, and Issue Date. The system cannot update custom data elements that are not listed in the Upload window.
Sample Multipart Form Request
Note: The form data body boundary in the example below is "—file upload—", but can be anything (or left unset).
-----file upload---
Content-Disposition: form-data; name="shortname"
unifier
-----file upload---
Content-Disposition: form-data; name="authcode"
MTIzMTIz
-----file upload---
Content-Disposition: form-data; name="dorevise" yes
-----file upload---
Content-Disposition: form-data; name="data"
[
{"Name":"ProjectDetails.doc","Owner":"Company Administrator","Creation Date":"01/01/2016","% Complete":"100","Description":"Fold 1" }
]
-----file upload---
Content-Disposition: form-data; name="0"; filename="b.txt" Content-Type: text/plain
test document contents
-----file upload-----
Sample Success Request
Send an request in the following format to upload the document, export (3).doc, from local storage:
http://<host>:<port>/ws/rest/service/v1/dm/document/create/713
projectnumber:AP
dorevise:yes
data:[{"Name":"export (3).doc"}]
Note: parent_node_id is provided as part of the path parameter in above REST call.
Sample Success Response
A successful message is displays in the following format when a ProjectDetails.doc document is successfully created in the Service docs folder:
{
"data": [{
"Path":"/test",
"from_object_id":"71
3",
"parentId":"713",
"Name"
:"export (3).doc"
}],
"message": [{"message": "OK", "status": 200 }],
"status": 200
}
Sample Failed Request
An invalid parent_node_id is sent in the following request:
http://<host>:<port>/ws/rest/service/v1/dm/document/create/71345
projectnumber:AP
data:[{"Name":"trial10.doc"}]
Note: The parent_node_id is provided as part of the path parameter in the above REST call.
Sample Failed Response
A failed response displays in the following format with status code 1045 for the above request when an invalid parent_node_id is specified:
{
"data": [ {
"Name": "ProjectDetails.doc"
}],
"message": [ { "message": "parent_node_id parameter is invalid", "status": 1046 }],
"status": 1045
}
Supported Validation Messages and Status Codes
The following validation messages and status codes display in the response when incorrect values are provided in the request.
Field Name | Use-case Scenario | Status code | Error Message |
---|---|---|---|
parent_node_id | parent_node_id is blank. | 500 | Server error. Contact System Administrator. |
parent_node_id | parent_node_id is invalid. | 1046 | parent_node_id parameter is invalid. |
projectnumber | projectnumber is invalid. | 602 | Project/Shell number is not correct. |
Name | Name is blank. | 1054 | Input required: Name |
Name | Name is not specified in the data JSON object. | 1054 | Input required: Name |
Name | Name is invalid (against the rules of naming). | 1048 | Invalid file name. |
Name | Existing name is specified(upper or lower case). | 1047 | File already exists in the path. |
dorevise | Random values are specified. |
|
|
% Complete | Characters are given | 200 | In UI, characters are not reflected instead "0" is kept. |
Description | Description exceeds 4000 characters. | 500 | Server error. Contact System Administrator. |
Related Topics
Update Document's Metadata by Path
Update Document Metadata by Document ID
Get Documents by Parent Folder ID
Search Document or Folder Properties
Rename Unpublished Document by File ID
Last Published Wednesday, April 9, 2025