Back

[SOLVED] 1.4.x REST API Function Create Execution - data payload

  • 0
  • Self Hosted
  • Functions
RedLeeder
20 Sep, 2023, 17:50

Hey All, I recently migrated to 1.4.3 and am running into issues around providing the data/payload to functions via the REST Endpoint (https://appwrite.io/docs/client/functions?sdk=rest-default#functionsCreateExecution).

Is that documentation up to date? Prior to 1.4.x the following code snippet worked.

TypeScript
const response = await fetch(
  "https://appwrite.<MyDomain>.com/v1/functions/<FunctionID>/executions",
  {
    method: "POST",
    headers: {
      "X-Appwrite-Project": "<ProjectID>",
      "Content-Type": "application/json",
      "X-Appwrite-Key": "<AppwriteKey>",
    },
    body: JSON.stringify({
      data: JSON.stringify({
        value1: "A",
        value2: "B",
      }),
    }),
  }
);

This is a new function built from the appwrite-cli template following 1.4.x standards.

The function executes but the req.bodyRaw & req.body values are empty.

This may be related to the new Custom Domains. I'm awaiting the DNS to refresh with a new CNAME Field but figured I'd reach out here in the meantime since the execution does still seem to be triggering.

Appreciate any assistance!

TL;DR
Title: [SOLVED] Issue with REST API Function Create Execution and data payload Message: The user was having issues providing the data/payload to functions via the REST Endpoint in Appwrite version 1.4.x. They shared the code snippet they were using, which worked prior to the update. However, after the update, the `req.bodyRaw` and `req.body` values were empty. The user suspected it might be related to the new Custom Domains feature. In a later message, they mentioned that the issue was resolved and thanked the community for their help. Solution: The user discovered that the issue was related
Drake
20 Sep, 2023, 17:56

the params have changed. take a look at the docs you linked again (make sure you're looking at the 1.4.x version of the docs)

RedLeeder
20 Sep, 2023, 17:59

So the browser/window size for my appwrite tab isn't 'large' so it wasn't showing me the Example Request. When I full screened it it popped up..I'll give that a whirl

RedLeeder
20 Sep, 2023, 18:40

Got it to work, appreciate it!

Working Syntax from my example:

TypeScript
const response = await fetch(
  "https://appwrite.<MyDomain>.com/v1/functions/<FunctionID>/executions",
  {
    method: "POST",
    headers: {
      "X-Appwrite-Project": "<ProjectID>",
      "X-Appwrite-Key": "<AppwriteKey>",
      "X-Appwrite-Response-Format": "1.4.0",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      body: JSON.stringify({
        value1: "A",
        value2: "B",
      }),
    }),
  }
);
Drake
20 Sep, 2023, 20:03

[SOLVED] 1.4.x REST API Function Create Execution - data payload

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