Let the platform do the work

//:record/file/:field POST

Overview

Attaches a file to a field on a record.

Request Arguments

Name Type Description Required
format String The data format. Currently accepts 'sugar-html-json'. True
delete_if_fails Boolean Indicates whether the API is to mark related record deleted if the file upload fails. False
oauth_token String The oauth_token value. False - Required if only if delete_if_fails is true.
<attachment field> String The field and file to populate.
Example: {"":"@\/path\/to\/ExampleDocument.txt"}
True

Request

{
   "format":"sugar-html-json",
   "delete_if_fails":true,
   "oauth_token":"43b6b327-cc70-c301-3299-512ffb99ad97",
   "<attachment field>":"@\/path\/to\/ExampleDocument.txt"
}

Response Arguments

Name Type Description
content-type String The files content type.
content-length Integer The files content length.
name String The files name.
uri String The URI of the file.

Response

{
   "content-type":"text\/plain",
   "content-length":16,
   "name":"ExampleDocument.txt",
   "uri":"http:\/\/sugarcrm\/rest\/v10\/Notes\/ca66c92f-5a8b-28b4-4fc8-512d099b790b\/file\/<attachment field>?format=sugar-html-json&delete_if_fails=1&oauth_token=6ec91cf3-1f97-25b9-e0b1-512f8971b2d4"
}

Change Log

Version Change
v10 Added /<module>/:record/file/:field POST endpoint.