I’m encountering a consistent issue with the /v2/expenses
API endpoint when attempting to upload an expense that includes a receipt
attachment. The API call works perfectly without the attachment, but as soon as I include any file — even a basic .txt
— the server returns a 500 Internal Server Error.
Working Example (No Attachment)
POST https://api.freeagent.com/v2/expenses
{
"expense": {
"user": "https://api.freeagent.com/v2/users/1915661",
"category": "https://api.freeagent.com/v2/categories/285",
"dated_on": "2025-04-21",
"description": "Test expense no attachment",
"gross_value": 100,
"currency": "GBP"
}
}
Response:
201 Created
Failing Example (With Attachment)
When adding a simple file like this:
'receipt' => new CURLFile('dummy_receipt.txt', 'text/plain', 'dummy_receipt.txt')
The same request structure returns:
HTTP/1.1 500 Internal Server Error
This occurs regardless of file type — .pdf
, .txt
, .jpg
— and from multiple servers and environments.
Troubleshooting Done
- Token, user, and category are all valid
- Same payload used across tests
- Curl verbose log confirms SSL and payload are sent correctly
- Attachment encoding verified (using
CURLFile
) - Error occurs only when receipt is attached
Could you help identify whether there’s an issue on the server side or something unexpected required in the upload format?
Happy to provide full curl
output and debug logs if useful.
Thanks in advance!