Issue Uploading Attachment via API – 500 Internal Server Error

Description:

I am attempting to upload an attachment using the ActivityInfo API, following the documentation provided here:

However, the request consistently fails with a 500 Internal Server Error.

I used Postman as following

  1. Open Postman.
  2. Create a new POST request to:

https://www.activityinfo.org/resources/form/cftfhpkmf2eselc9/record/c2v1l16mf3nrfh72/field/cum12dsmf2esqgmb/blob

  1. Set Authorization to Basic Auth:
  • Username: anything
  • Password: <API Token with Read & Write access>
  1. In the Body, select form-data and configure:
  • Key: file
  • Value: uploaded text file (for testing).

The server returns the following error:

500 Internal Server Error
The server has encountered a situation it does not know how to handle.

{
“code”: “INTERNAL_SERVER_ERROR”,
“message”: “An unexpected exception occurred while handling the request”,
“localizedMessage”: null
}

Hi @Ali_Nasser,

Sorry, it looks like the documentation for this endpoint is incomplete. I’m adding a ticket to improve it, but here are some quick details that might help:

The required mime type is multipart/form-data and the endpoint expects two parts:

  • file: containing the attachment to upload
  • blobId: a client-generated unique id for the attachment. This is the Id that you would use when adding the record with the attachment.

The blobId must match the pattern [a-z][a-z0-9]{0,25} and must be unique within the form. Our own web client uses the CUID algorithm.

Does this work?

Alex

1 Like

Dear @Alex,

Thank you so much, it worked.

Regards,
Ali