Hi guys, what am I doing wrong? I am sending the postman request to my function. The header contains only a content-type = application/json; charset=UTF-8. From this request and receive a 500 internal server error.
Here is the function:
String requestBody = jsonEncode(context.req.body); context.log(requestBody); String userId = context.req.body['user_id']; context.log(context.req.body['text']); if (await userExists(userId)) { List? response = await getStatusCode(context.req.body['text']); return context.res.json({'status': response![0], 'text': response[1]}); } else { return context.res.json({'status': 400, 'text': 'User does not exist'}); }
The requestBody variable is an empty string "". Why?
Log and check the execution logs if response[1] does have non-empty text
Also have you set the right execute permissions for function?
The permission is set on Any.
So I could solve the problem with Postman. But I get the error "Execution timed out.". I suppose this is because the function call the ChatGPT API which takes times to return an answer. How can I solve this issue?
The other issue occurs if I send the request to the function from my code:
final response = await http.post(
Uri.parse('https://65fd719a7c3c7d2c8e8c.appwrite.global'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Connection': 'keep-alive',
'Accept-Encoding': 'gzip, deflate, br',
'Accept': '*/*',
'Host': '65fd719a7c3c7d2c8e8c.appwrite.global',
},
body: jsonEncode(<String, String>{
'user_id': userId,
'text': text,
}),
);
In this case, the request body is an empty string. This should not be empty.
The log of the request from the code shows that the HTTP method is an OPTIONS.
Recommended threads
- Provider error when creating a function ...
- Function deployment failed: Unable to re...
Hi Appwrite team, I have been experiencing persistent errors when i attempt to push my appwrite functions. The logs on the deployment detail page on the console...
- My cloud functions failing 3 days ago (P...
Hi, My cloud function using python has been failing for 3 days, I didn't push any new deployments... Its something to do with it not recognising the entrypoi...