Appwrite Function Not Receiving HTTP Request Body (req.payload, req.body, and req.bodyRaw all empty) on Cloud (nyc region)
👟 Reproduction steps
Description: I am unable to get my Appwrite Function (Node.js 18, deployed in the nyc region) to receive the HTTP request body when triggered via the REST API. The function always receives req.payload, req.body, and req.bodyRaw as undefined or empty, even though the request is sent with the correct Content-Type and a nonzero content-length.
Function Code:
module.exports = async ({ req, res, log, error }) => {
// Debug: log the full req object and possible body locations
try {
log('req.payload:', req.payload);
log('req.body:', req.body);
log('req.bodyRaw:', req.bodyRaw);
log('Full req:', JSON.stringify(req));
} catch (e) {
log('Error logging req object:', e);
}
// Parse payload from Appwrite REST/SDK or local
let raw = req.payload;
if (!raw && req.bodyRaw) {
raw = req.bodyRaw;
}
if (!raw && req.body) {
if (typeof req.body === 'string') {
raw = req.body;
} else if (req.body.data) {
raw = req.body.data;
}
}
log('Raw payload value:', raw);
if (!raw) {
error('Missing payload! req.payload:', req.payload, 'req.body:', req.body, 'req.bodyRaw:', req.bodyRaw);
throw new Error('Missing payload');
}
const payload = JSON.parse(typeof raw === 'string' ? raw : JSON.stringify(raw));
log('Payload parsed:', payload);
return res.json({ payload, body: req.body, bodyRaw: req.bodyRaw }, 200);
};
How I’m Triggering the Function:
Using both frontend code (fetch and axios) and direct curl requests. Example curl command:
curl -X POST 'https://nyc.cloud.appwrite.io/v1/functions/68c358e4001be6aa5c0c/executions' \
-H 'Content-Type: application/json' \
-H 'X-Appwrite-Project: 68bfaa37002cf15d8be9' \
-d '{"test":"hello"}'
Observed Appwrite Function Execution Logs:
--- Incoming request to storeUser.js ---
Request method: POST
Request payload: undefined
Request body:
Request bodyRaw:
Error logging req object: SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at get bodyJson [as bodyJson] (/usr/local/server/src/server.js:125:21)
at JSON.stringify (<anonymous>)
at module.exports (/usr/local/server/src/function/storeUser.js:9:27)
at execute (/usr/local/server/src/server.js:222:22)
at action (/usr/local/server/src/server.js:237:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /usr/local/server/src/server.js:26:5
Raw payload value: undefined
--------
Missing payload! req.payload: undefined req.body: req.bodyRaw:
Internal error: Error: Missing payload
at module.exports (/usr/local/server/src/function/storeUser.js:51:13)
at execute (/usr/local/server/src/server.js:222:22)
at action (/usr/local/server/src/server.js:237:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /usr/local/server/src/server.js:26:5
👍 Expected behavior
What I Expect: The function should receive the request body as req.payload, req.body, or req.bodyRaw, but all are empty.
What I’ve Tried:
Sending the body as a raw JSON string with correct headers. Using both axios and fetch in the frontend. Testing with direct curl requests. Logging all possible request properties. Function runtime is Node.js 18, and all environment variables are set. Verified that content-length and content-type are correct. No proxy or firewall is interfering. Impact: This blocks all HTTP-based function use cases that require a request body, including user authentication and database writes.
Environment:
Appwrite Cloud (nyc region) Node.js 18 function runtime Function ID: 68c358e4001be6aa5c0c Project ID: 68bfaa37002cf15d8be9 Please advise if this is a known issue, or if there is a workaround.
👎 Actual Behavior
Impact: This blocks all HTTP-based function use cases that require a request body, including user authentication and database writes.
Environment:
Appwrite Cloud (nyc region) Node.js 18 function runtime Function ID: 68c358e4001be6aa5c0c Project ID: 68bfaa37002cf15d8be9
🎲 Appwrite version
Appwrite Cloud
💻 Operating system
Linux
🧱 Your Environment
Environment:
Appwrite Cloud (nyc region) Node.js 18 function runtime Function ID: 68c358e4001be6aa5c0c Project ID: 68bfaa37002cf15d8be9
👀 Have you spent some time to check if this issue has been raised before?
- [x] I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- [x] I have read the Code of Conduct
I'm having this exact same issue and I cannot find a solution. If I run the execution through the appwrite console it works perfectly fine. Trying to run it via url from my client, or through Postman fails with an empty body. I've tried logging req.body, req.bodyText, req.payload. Doesn't matter what I try, it's empty. I've tried sending json with the application/json header. I've tried sending plain text with text/plain.
Nothing works. Is there some setting or something that's meant to be set? I'm on the Sydney region using node.js 22. I feel like this should be simple, tearing my hair out here.
Just in case anyone else comes across this. I finally figured it out. The endpoint needed to be the domain url listed under the domain tab of the function, not the region endpoint url.
🎯 Agentic Issue Triage
UPDATE: This issue has been resolved by the original reporter. The problem was using the wrong endpoint URL.
Summary: Appwrite Functions were not receiving HTTP request body when triggered via the REST API. User discovered the solution: must use the function domain URL (from Domains tab) instead of the region endpoint URL.
(strong)✅ Resolution(/strong)
Solution Found (by @gtrafford):
"Just in case anyone else comes across this. I finally figured it out. The endpoint needed to be the domain url listed under the domain tab of the function, not the region endpoint url."
Correct Endpoint Usage:
❌ Wrong (Region Endpoint):
curl -X POST '(redacted)}/executions' \
-H 'Content-Type: application/json' \
-d '{"test":"hello"}'
✅ Correct (Function Domain):
# Use domain from Function > Settings > Domains tab
curl -X POST '(redacted)}.cloud.appwrite.io' \
-H 'Content-Type: application/json' \
-d '{"test":"hello"}'
Why This Matters:
-
Region endpoint (
/v1/functions/.../executions): Creates execution record, may not pass body correctly to function - Function domain: Direct function invocation with full HTTP context including request body
(strong)🔍 Issue Analysis(/strong)
Original Problem:
-
req.payload,req.body, andreq.bodyRawwere all empty - Occurred on Appwrite Cloud (NYC and Sydney regions)
- Node.js 18 and 22 runtimes
- Affected both fetch/axios and curl requests
- Console execution worked fine
Root Cause: Using the wrong API endpoint - execution API vs function domain URL
Lessons Learned:
- Function domain URLs and execution API endpoints behave differently
- Console execution works because it uses proper invocation method
- Documentation could be clearer about endpoint differences
(strong)📚 Documentation Improvements Needed(/strong)
This issue highlights a documentation gap that causes confusion:
Suggested Documentation Enhancements:
-
Clearly Distinguish Endpoint Types:
📌 Two Ways to Invoke Functions: 1. Via Execution API (Async): POST /v1/functions/{functionId}/executions - Creates an execution record - Returns execution ID immediately - May have different body handling 2. Via Function Domain (Synchronous): POST (redacted)}/ - Direct HTTP invocation - Full request body support - Real-time response -
Add Prominent Note in Function Docs:
⚠️ Important: When sending HTTP request body to functions, use the function domain URL (found in Settings > Domains), not the execution API endpoint.
-
Update Code Examples:
- Show both methods clearly
- Highlight when to use each
- Include body passing examples
-
Add Troubleshooting Section:
- "Request body is empty" → Check endpoint type
- "Function works in console but not API" → Use function domain
- Common pitfalls and solutions
(strong)🔗 Related Issues(/strong)
Potentially Related Issues (this repo):
No direct matches found, but this is likely a common point of confusion for new users.
Related Concepts:
- Function invocation methods
- HTTP request body handling
- Function domains vs API endpoints
- Execution API behavior
(strong)🎯 Recommended Actions(/strong)
For Documentation Team:
- [ ] Add clear distinction between execution API and function domains
- [ ] Update function invocation examples
- [ ] Add troubleshooting section for body handling
- [ ] Highlight function domain usage in quick-start guides
- [ ] Add warning/note about endpoint differences
For Product Team (Nice to Have):
- [ ] Consider making execution API handle body consistently
- [ ] Add UI hint about which endpoint to use when
- [ ] Show example curl commands for both methods
- [ ] Add validation/warning when body sent to execution API
For This Issue:
- [ ] Close as resolved (user found solution)
- [ ] Extract documentation improvements to new issue
- [ ] Link to updated docs once published
Priority Assessment: Resolved (but documentation improvement needed)
The issue itself is resolved, but it exposed a significant documentation gap that likely affects many users.
Suggested Actions:
- Close this issue as resolved
- Thank contributors for sharing the solution
- Create a documentation enhancement issue
- Link related users to the solution
🤖 This triage was performed by an AI agent. The analysis is provided to help the team understand and prioritize the issue.
✅ Issue Status: Resolved - Use function domain URL instead of execution API endpoint for HTTP body support.
AI generated by Agentic Triage
To add this workflow in your repository, run
gh aw add githubnext/agentics/workflows/issue-triage.md@0837fb7b24c3b84ee77fb7c8cfa8735c48be347a. See usage guide.