Skip to content

Transaction Upload API

Tom Bloor edited this page Apr 22, 2017 · 4 revisions

Transaction Upload API

Last Updated 2017-04-22

POST /api/upload

Takes a multipart/form-data upload, with the following parts:

  • File under the form key file with the content type image/jpeg
  • JSON Object with required arguments under json key

The JSON can be one of the following types:

  • Known and Validated Organisation
  • Known but Unvalidated Organisation
  • Unknown Organisation

Request JSON

Known and Validated Organisation

{
  session_key : <current session key>,
  transaction_type : 1,
  transaction_value : 2.99,
  organisation_id : <id_number>
}

Known but Unvalidated Organisation

{
  session_key : <current session key>,
  transaction_type : 2,
  transaction_value : 2.99,
  organisation_id : <id_number>
}

Unknown Organisation

{
  session_key : <current session key>,
  transaction_type : 3,
  transaction_value : 2.99,
  organisation_name : 'Org Name',
  street_name : '7 High Street',
  town : 'Lancaster',
  postcode : 'LA1 1AA',
}

Note street_name and postcode are optional.

Response JSON

Success

Response code of 200 OK

{
  success : true,
  message : 'Upload Successful'
}

Failure

If something is missing from the request, or is invalid, you will get a response code of 400 BAD REQUEST and the following:

{
  success : false,
  message : <error message>
  error : <error type>
}

If there was a server error, you will get a 500 SERVER ERROR and possibly the following:

{
  success : false,
  message : 'An unknown error occurred when adding the transaction'
  error : 'server_error'
}

The error messages should describe what was wrong with the submission