Attachment Upload

Uploads an attachment.

Attachment Upload

ParameterMandatoryDescriptionExamplesMore Info
APIYesThe API areaexpenselines.json
GeneralYesParameters described in overviewAuthorization: Bearer <access_token> header — see Synergist API AuthenticationStructure of an API call
CompanyYesThe company numbercompany=1
ActionYesThe action to performaction=update
IdentifierYesExpense line UUIDuuid=1234
InputYesJSON stringSee below
JSON InputMandatoryDescriptionExamples
Base64YesBase64 string"variable_AttachmentBase64":"SEVSRSBJUyBTT01FIFRFWFQNCg=="
AttachmentFileNameYesFile name"variable_AttachmentFileName":"Receipt.jpg"
IdentifierYesExpense line ID"expenselines_expenselineinternal":"3398"

Only one identifier needs to be passed, either the UUID in the URL or the Internal ID in the JSON string.

Before calling this endpoint you should first ascertain if the Synergist system being accessed is using Amazon S3 to attachment storage. This can be determined by using the System API. If S3 is being used it is not necessary to pass the Base64 string. In this case the response will include the data required to perform a PUT using Amazon's API.

Example request (OAuth 2.0):

Authorization: Bearer <access_token>
http://<SERVER>/jsonapi/expenselines.json?&version=6&action=update&input={
  "data": [
    {
      "variable_AttachmentBase64": "77u/dGV4dA==",
      "variable_AttachmentFileName": "text.txt",
      "expenselines_expenselineinternal": "4022"
    }
  ]
}

Example request (legacy username/password):

http://<SERVER>/jsonapi/expenselines.json?&version=6&action=update&input={
  "data": [
    {
      "variable_AttachmentBase64": "77u/dGV4dA==",
      "variable_AttachmentFileName": "text.txt",
      "expenselines_expenselineinternal": "4022"
    }
  ]
}&user=<username>&password=<password>

Example response (Amazon S3 systems):

{
  "responsecode": 1,
  "responsestatus": "OK",
  "errorcode": 0,
  "errormessage": "",
  "responsemessage": "data processed successfully.",
  "warningmessage": "",
  "success": true,
  "synapiversion": 3.8,
  "data": [
    {
      "attachmentS3UrlGet": "https://syn-test.s3-eu-west-1.amazonaws.com/text_7138.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA4ZGRNZLLUTWA6XH2/20201116/eu-west-1/s3/aws4_request&X-Amz-Date=20201116T151443Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=b1aad3678254a6ef7ce7ee937d637d775c01521e80fbad767d3df898294e2d27",
      "attachmentS3UrlPut": "https://syn-test.s3-eu-west-1.amazonaws.com/text_7138.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA4ZGRNZLLUTWA6XH2/20201116/eu-west-1/s3/aws4_request&X-Amz-Date=20201116T151443Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=8c2d678fb3149097d6ab46162a339bb0878cbfa8895c2a0e6576824b74023d43",
      "expenselineInternal": 4022,
      "expenselineUuid": "65B30EF127A88149A515AF4DB1931532",
      "expenselineTimestampModified": 1605539275,
      "expenselineRecordVersionNumber": 1
    }
  ]
}

Example response (non-S3 systems):

{
  "responsecode": 1,
  "responsestatus": "OK",
  "errorcode": 0,
  "errormessage": "",
  "responsemessage": "data processed successfully.",
  "warningmessage": "",
  "success": true,
  "data": [
    {
      "expenselineInternal": 4022,
      "expenselineUuid": "65B30EF127A88149A515AF4DB1931532",
      "expenselineTimestampModified": 1605539275,
      "expenselineRecordVersionNumber": 1
    }
  ]
}