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
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...
- Function in Node.JS to monitor events ar...
Hello everyone. I'm creating my first Node.JS function, but I don't have much experience with node and javascript. I'm trying to create a function, that monito...