When I execute a NodeJS function via the Cloud console, I get this request header: "content-type":"application/x-www-form-urlencoded"
This breaks things since my code is expecting a JSON payload.
So I manually set the content type to application/json with the Headers field shown in the screenshot. When this runs, it fails in 1-3 ms and there are no errors whatsoever to troubleshoot (see screenshot).
I've tried variations of this input such as "Content-Type" content-type Content-Type "application/json" ... etc. Doesn't work.
I then tried using a cURL command to hit the endpoint directly with the headers set and it works without any issues.
This leads me to believe that the Cloud Console's Headers field isn't working properly.
You can try
const body = JSON.parse(req.bodyRaw)
Thanks! I'm aware of this workaround. I plan on introducing custom headers in the near future so this extends beyond just being able to define the content type.
Can you check the network logs for the request from the Console and check the payload?
What was the curl you executed?
This is odd. It seems to be working now. I ran a few with UI. I guess I'll open another issue if I see it again. But for your reference, I was using
curl -X POST <endpoint>.appwrite.global/feedback \
-H "Content-Type: application/json" \
-d '{"name": "panda", "email": "fake@placeholder.com", "message": "ur awesome", "userId": "12345"}'
Fyi, when executed via the console, the create execution API is called and it's executed asynchronously. This behaves slightly differently than calling the function domain
[SOLVED] Function Headers in Cloud Console Is Broken
Recommended threads
- Unknown usage from one of my database
I need support help. For more than 2 weeks, i didn't make any requests to my database, but I have noticed huge amount of reads and writes requests: Around 8000...
- Bug in cloud console?
Hi, I just created a new project, wanted to add a web platform and next to "host name" is says "optional" but I have to choose a valid hostname? Seems like a b...
- AppwriteException: Missing required para...
I'm using node-appwrite sdk to retrive the documents. Example my code on pic, was define collectionId but error is still. Why?