When the Sage CRM REST API was released in Sage CRM 2019 R2 it covered the core entities within Sage CRM and that included the library. Using the API it was possible to view, insert, update and delete records in the library (document) table. There was, however, a rather obvious gap in the API. There was no obvious way to upload the physical files that the library records control.
In Sage CRM 2021 R1 we have added support for two endpoints that will allow documents to be uploaded.
Note: This article assumes that you have downloaded and imported the Postman Collection that contains examples of the new endpoints.
The upload method is shown being used in Postman below.
The file to be uploaded is attached using the POST section 'hiddenFileUpload' field.
If the upload is successful then a status of 'Success' will be returned.
The fileUpload endpoint allows only one file at a time can be uploaded. If you attempt to upload multiple files then only the first will be processed.
The file will be uploaded into a temporary folder.
Note: The temporary folder has the same name as the Session ID used to authenticate the post.
Once the file is uploaded it can be moved to its final library destination using the serverside code (.NET API, ASP etc) using the FileSystem object or equivalent.
To remove the files from the temp folder you will use the endpoint
This will remove all files within the Temp folder created and used by the fileUpload.