/Documents/:record/file/:field PUT
Overview
This endpoint takes a file or image and saves it to a record that already contains an attachment in the specified field. The PUT method is very similar to the POST method but differs slightly in how the request is constructed. PUT requests should send the file data as the body of the request. Optionally, a filename query parameter can be sent with the request to assign a name. Additionally, the PUT
method can accept base64 encoded file data which will be decoded by the endpoint
if the content_transfer_encoding parameter is set to 'base64'.
NOTE: In lieu of the content_transfer_encoding parameter, a
request header of X-Content-Transfer-Encoding can also be sent with a value
of 'base64'. In the event both the content transfer encoding header and request
parameter are sent, the header will be used.
Request Arguments
Name |
Type |
Description |
Required |
filename
|
String
|
Filename to save the document as
|
False
|
content_transfer_encoding
|
String
|
When set to 'base64', indicates the file contents are base64 encoded
and will result in the file contents being base64 decoded before being
saved
|
False
|
Request
PUT /rest/v10/Notes/abcd-1234/file/field/ HTTP/1.1 Host: localhost Connection: keep-alive Content-Length: 23456 Content-Type: application/document-doc ...This is where the bin data would be
Response Arguments
Name |
Type |
Description |
field
|
Array
|
The fields containing file properties.
|
field.content-type
|
String
|
The files content type.
|
field.content-length
|
Integer
|
The files content length.
|
field.name
|
String
|
The files name.
|
field.width
|
Integer
|
The width of the image.
|
field.height
|
Integer
|
The height of the image.
|
field.uri
|
String
|
The URI of the file.
|
Response
{
"picture":{
"content-type":"image\/png",
"content-length":72512,
"name":"1a7b8f5c-b11c-0094-c8d8-512e9daaa983",
"width":933,
"height":519,
"uri":"http:\/\/sugarcrm\/rest\/v10\/Contacts\/fa300a0e-0ad1-b322-9601-512d0983c19a\/file\/picture"
}
"attachment":{
"content-type":"application/document-doc",
"content-length":"873921",
"name":"myFile.doc",
"uri": "http:\/\/sugarcrm\/rest\/v10\/Contacts\/f2f9aa4d-99a8-e86e-f4d5-512d0986effa\/file\/attachment"
}
}
Change Log
Version |
Change |
v10
|
Added /<module>/:record/file/:field PUT endpoint.
|