Once you have acquired and used an access token (see Getting Started), you can start creating documents in the Hyland Experience repository and assigning access privileges to them.
To create a document:
- Open Command Prompt or Terminal.
-
Enter the following request to create a new document at the root level of the
repository:
curl -i -X POST [base_url]/api/documents/00000000-0000-0000-0000-000000000000 \ -H "Authorization: Bearer [access_token]" \ -H "User-Agent: [product]/[version]" \ -H "Content-Type: application/json" \ -d "{\"sys_primaryType\": \"SysFile\", \"sys_title\": \"My File\"}"
where the placeholders represent the following:
Placeholder Description [base_url] The URL of the Hyland Experience repository [access_token] The access token you retrieved when you completed authentication [product] The name of the software you are using to make the request [version] The numbered version of the software A response that includes the structure of your newly created document is displayed, as shown in the following example:
{ "sys_id": "63a5f989-9ce8-4605-8c3a-0697084b9453", "sys_isCheckedIn": false, "sys_isLatestMajorVersion": false, "sys_isLatestVersion": false, "sys_isProxy": false, "sys_isTrashed": false, "sys_isVersion": false, "sys_mixinTypes": [ "SysVersionable" ], "sys_name": "My File", "sys_parentId": "00000000-0000-0000-0000-000000000000", "sys_path": "/My File", "sys_primaryType": "File", "sys_repository": "default", "sys_title": "My File", "sys_versionLabel": "0.0", "sys_contributors": [ "d857a535-df7c-49da-aec3-e26ad728594d" ], "sys_created": "2022-01-01T00:00:00.000+00:00", "sys_creator": "d857a535-df7c-49da-aec3-e26ad728594d", "sys_lastContributor": "d857a535-df7c-49da-aec3-e26ad728594d", "sys_modified": "2022-01-01T00:00:00.000+00:00", "sys_title": "My File" }
-
To modify the new document's ACL, use the document's ID as you enter a request
similar to the following example:
curl -i -X PUT [base_url]/api/documents/[sys_id] \ -H "Authorization: Bearer [access_token]" \ -H "User-Agent: [product]/[version]" \ -H "Content-Type: application/json" \ -d "{\"sys_acl\": [{\"user\": {\"username\": \"anothertestuser\", \"id\": \"[anothertestuser_id]\"}, \"permission\": \"Read\", \"granted\": true, \"creator\": \"testuser\", \"begin\": \"2022-01-01T00:00:00Z\", \"end\": \"2023-01-01T00:00:00Z\"}]}"
where [sys_id] is the ID of the document you created in step 2 and [anothertestuser_id] is a unique string ID you can specify for a user as you grant them access privileges.
A response similar to the one in step 2 is displayed, only this new response includes ACL-related properties, such as sys_acl and sys_effectiveAcl:
{ "sys_acl":[ { "begin": "2022-01-01T00:00:00Z", "creator": "testuser", "end": "2023-01-01T00:00:00Z", "granted": true, "permission": "Read", "principal": { "user": { "id": "anothertestuser", "username": "anothertestuser" } }, "status": "EFFECTIVE" } ], "sys_effectiveAcl": [ { "begin": "2022-01-01T00:00:00Z", "creator": "testuser", "end": "2023-01-01T00:00:00Z", "granted": true, "permission": "Read", "principal": { "user": { "id": "anothertestuser", "username": "anothertestuser" } }, "status": "EFFECTIVE" } ], "sys_id": "63a5f989-9ce8-4605-8c3a-0697084b9453", ... }
For more information on the response body elements shown in these examples, see Document.