Adding an Attachment

Usage

Adds an attachment to a document.

Request

POST /documents/<documentID>/attachments

Request type: multipart/form-data

Request body:

--------------------####boundary123456798
Content-Disposition: form-data; name=""attachmentInfos""
Content-Type: application/xml

<attachment>
    <name>sales_report</name>
    <mimeType>image/png</mimeType> <!--Optional-->
    <size>123</size>
</attachment>

--------------------####boundary123456798
Content-Disposition: form-data; name=""attachmentContent""; filename=""logo_picture.png""
Content-Type: image/png

(Content of file)
--------------------####boundary123456798

The multipart body request allows at least two parts:

  • The information about the attachment (attachmentInfos)
  • The attachment content (attachmentContent)

In case of image upload, the mime types accepted are the following:

  • image/png
  • image/jpeg
  • image/gif
  • image/bmp
Response

Response type: application/xml or application/json

The response is a message stating the success or failure of the request.

Example

CURL command:

curl -i -X "POST" -H "accept:application/xml" 
-H "content-type:multipart/form-data" -H X-SAP-LogonToken:"""%tokenValue%"" -F "attachmentInfos=@attachment.xml”
 -F ”attachmentContent=@<file_to_be_uploaded>” http://<serverName>:6405/biprws/raylight/v1/documents/3422/attachments

Request body:

<attachment> 
    <mimeType>image/png</mimeType>
    <name>myResourceName</name>
    <description>myResourceDescription</description>
</attachment>

Response:

<success>
    <message>The resource of type "Attachment" has been successfully created.</message>
    <id>9994</id>
</success>