Skip to content
Back

Error 500, when running function without body

  • 0
  • Self Hosted
  • Functions
  • REST API
Ibaraki Douji
17 Mar, 2025, 16:53

So i wanted to run a function, tho i don't have any body on this one, and when executing, i got an error 500.

Code:

TypeScript
const client = new AppwriteClient()
    .setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
    .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
  const functions = new Functions(client);
  const f = await functions.createExecution("67d8394c0038d8f14c00", null, false);

SDK Error:

TypeScript
AppwriteException: Server Error
    at _Client.call (file://<file>)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handler (file://<file>) {
  code: 500,
  type: 'general_unknown',
  response: '{"message":"Server Error","code":500,"type":"general_unknown","version":"1.6.1"}'
}

API/Server Error:

TypeScript
2025-03-17T16:46:20.244116082Z [Error] Timestamp: 2025-03-17T16:46:20+00:00
2025-03-17T16:46:20.244211771Z [Error] Method: POST
2025-03-17T16:46:20.244232189Z [Error] URL: /v1/functions/:functionId/executions
2025-03-17T16:46:20.244237238Z [Error] Type: TypeError
2025-03-17T16:46:20.244242228Z [Error] Message: {closure}(): Argument #2 ($body) must be of type string, null given, called in /usr/src/code/vendor/utopia-php/framework/src/App.php on line 607
2025-03-17T16:46:20.244247346Z [Error] File: /usr/src/code/app/controllers/api/functions.php
2025-03-17T16:46:20.244252145Z [Error] Line: 1768

After a look, i changed the body from null to "" and it worked, tho i think there is some missing checks (convert null body to something, prevent null in the SDK, better SDK error description)

TL;DR
Error 500 occurred when executing a function without a body in the code. Changing the body from `null` to `""` resolved the issue. Developers suggested implementing better checks to handle null bodies in the SDK and improving the error descriptions.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more