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
- Domain Verification Failed - Fastly Conf...
I am trying to add my subdomain api.getmyself.app to my Custom Domain, but I keep getting the error: Domain 'getmyself.app' is owned by another customer I have...
- Data not loading at the frontend
My App that has been working for weeks, ain't loading anything at the frontend anymore. I thought maybe the API key expired but it's not the case. Users are log...
- Function for long running task (other 60...
My function need long running other 60 seconds. But async mode return empty body. How to deal with that please ?