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
- DeploymentStatus enum value `canceled` m...
Hey, Sorry if it has been reported already, I found an issue using the Dart SDK where the `canceled` enum value is missing from `DeploymentStatus`. This causes...
- Frequent 500 Internal Server Errors - Pr...
PROJECT ID: 6951f2xxxxx1ee9e750a REGION: Singapore (sgp.cloud.appwrite.io) PLAN: Pro Our production application experiences **500 Internal Server Errors** mult...
- Issue with Custom SMTP
Hey everyone, I'm facing an issue when updating my Custom SMTP settings on Appwrite Cloud. The UI fails silently (no visual errors), but when checking the cons...