Table of Contents


Uploading Documents

Publicly available documents can be uploaded into Magentrix with an HTTP POST operation. The document is stored as a file in the document library, Notes and Attachments, or Salesforce Files.

If Id is provided:

  • Document: Metadata will be updated. If a file download URL is provided, a new version will be added.
  • Attachment: Existing attachment will be overwritten.
  • Salesforce Files: A New version was added.

Validations are in place to check the Token (sessionId) user's permissions to create and edit files in the parent location.

POST https://<your-portal-domain>/rest/2.0/file
  -H "Authorization: Bearer <token>"
  -H "Content-Type: application/json"
  -H "Accept: application/json"

Body payload:

{ 
    "Id": "<Magentrix Id of file if uploading new file version>",
    "File": "<Public download URL of file>",
    "FileName": "<File name and extension>",
    "Title" : "<Document title>",
    "Description": "<Document description>", 
    "ParentId": "<Folder ID or Parent Record ID>", 
    "Type": "<document OR attachment OR salesforce file>", 
    "ContentType": "<content type e.g. application/ms-word>"
}

Note: If a Record ID is provided, "File" parameter is not mandatory. If "File" parameter is not passed, Magentrix will only update the file metadata. For updates, only the field values provided will be updated, and the rest will be preserved.

The type parameter is a mandatory value and must be provided. ParentId defines which folder a document should upload under or which record the file should be attached to, such as Opportunity or Account.

Note: file size limits are the same as limits applied to Magentrix Documents or Salesforce Files.
 

Note: The source domain of the files should be white-listed in Magentrix for security reasons.

Example payload for updating an existing file:

{ 
    "Id": "7Ot00000000FXzb009Q",
    "File": "https://docs.google.com/document/d/1CGnFEOIolBUpEoE0ZflodJPCtWB7E9qVWqCufKYsk3g/export?format=doc",
    "FileName": "RESTUpload.docx",
    "Title": "LMS courses and lessons",
    "Description": "From Google Drive", 
    "ParentId": "7Os00000000003Z009Q", 
    "Type": "document", 
    "ContentType": "application/ms-word"
}