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
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...
- Function domain not available
Hello, even tho in docs you clearly describe that every function has its domain, I can not see it anywhere in any of my projects. How do I reveal the url of th...