Write Attachment


Writing attachments is done in different ways.
Checkout the cases below for more information.

Case 1

When creating an object the attachment can be included directly as an Attachment object.
Make sure the commonName, originalLocation, mimeType and contentsB64String are filled. The contentsB64String are the actual contents of the attachment.
This way of attachment creating is used for sending chat messages with attachments, creating phone lines with voicemail, etc.

Request
POST https://xelion.nl/api/v1/master/phonelines
Payload
{
    "commonName": "testline1234",
    "voicemailDeliveryMessage":
    {
        "originalLocation": "xcc_audio8228483372635530249.wav",
        "commonName": "xcc_audio8228483372635530249.wav",
        "mimeType": "audio/wav",
        "contentsB64String": "UklGRnCaAABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YUyaAAAAAAAA//8AAAAAAAAAAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//AAAAAAAAAAAAAAAAAAAAAAAAAQAAAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAasdfartuhsuifaskdf8nasdfnNBBBP"
    },
    "objectType": "XCCPhoneLine"
}
Response
{
    "object": {
        "voicemailDeliveryMessage": {
            "originalLocation": "xcc_audio8228483372635530249.wav",
            "mimeType": "audio/wav",
            "size": 0,
            "commonName": "xcc_audio8228483372635530249.wav",
            "oid": "1856721",
            "objectType": "Attachment"
        },
        "permissions": "ReadWriteRemove",
        "commonName": "testline1234",
        "oid": "1856704",
        "objectType": "XCCPhoneLine"
    },
    "links": [
        {
            "rel": "self",
            "href": "https://xelion.nl/api/v1/master/phonelines/1856704",
            "method": "GET"
        }
    ]
}

Case 2

When an object is already created you can update an object attachment member with a patch call. If you want update the attachment contents there are 3 options.
1. set the patch operation path "/member/contentsB64String" and set the base64 String value for the contents of the attachment.
2. set the patch operation path "/member/contentsAudioFile" and set the Audio File oid as value.
3. set the patch operation path "/member/contentsRef" and set the Attachment oid as value.

If you want to remove an attachment then make an operation remove on the member ("op:"remove","path":"/voicemailDeliveryMessage").
This way of attachment modification is used for updating phone lines voicemail, announchment etc.

Request
PATCH https://xelion.nl/api/v1/master/phonelines/1856704
Payload
{
  "operations": [
      {
      "op": "replace",
      "path": "/voicemailDeliveryMessage/contentsB64String",
      "value": "UklGRnCaAABXQVZFZm10IBAAAAABAAEAQB8AAAAAAAAAasdfartuhsuifaskdf8nasdfnNBBBP"
      },
      {
      "op": "replace",
      "path": "/voicemailDeliveryMessage/contentsAudioFile",
      "value": "123456"
      }
      {
      "op": "replace",
      "path": "/voicemailDeliveryMessage/contentsRef",
      "value": "78910"
      }
  ]
}

Case 3

In some cases the attachment can be uploaded with a binary file uploader. The name and mimetype can be set through the headers Content-Type and Content-Disposition. In some cases the filename is set with the API path.

with filename in headers

Request
POST https://xelion.nl/api/v1/master/server/chats/1478451/concept/attachment
Payload
image.jpg

with filename in path

Request
POST https://xelion.nl/api/v1/master/server/update/xcc6_update20.dat
Payload
xcc6_update20.dat