
Hello everyone, Can someone help me on identifying what's wrong with my curl request? It works fine If I try through Console
{
curl --request POST \
--url http://MY_MACHINE_IP_LOCALHOST:80/v1/functions/MY_FUNCTION_ID/executions \
--header 'Content-Type: application/json' \
--header 'X-Appwrite-Key: MY_APPWRITE_KEY' \
--header 'X-Appwrite-Project: MY_PROJECT_ID' \
--data '{
"data": "{\"sender\":\"valid@mail.com\",\"body\":\"<!DOCTYPE html><html><head><title>Mensagem HTML Simples</title></head><body><h1 style=\\\"color: blue;\\\">Mensagem HTML Simples</h1><p>Esta é uma mensagem HTML de exemplo.</p><p>Você pode personalizá-la como desejar.</p></body></html>\",\"subject\":\"Testing Email Sending with Functions\",\"recipients\":[{\"email\":\"valid@mail.com\",\"name\":\"William Cardoso\"}]}"
}
'
My requests throws error since no data is recognized. How to properly execute it? I am using Insomnia

Try to remove the :80
Like so
--url http://MY_MACHINE_IP_LOCALHOST/v1/functions/MY_FUNCTION_ID/executions \

Yeah still gives the same error. Also, I tried sending a simple data imaging maybe something is wrong with my data, but also gives same error: data is empty.
Also, it is reaching console since it is listing the failed executions there. I just can't understand why data/body is going empty since I am defining it.

What response you're getting?

Even with: '{"data":"this is json data"}'
I am getting:
"errors": "On Catch FormatException: Unexpected end of input (at character 1)\n\n^\n\nStacktrace #0 _ChunkedJsonParser.fail (dart:convert-patch\/convert_patch.dart:1383)\n#1 _ChunkedJsonParser.close (dart:convert-patch\/convert_patch.dart:501)\n#2 _parseJson (dart:convert-patch\/convert_patch.dart:36)\n#3 JsonDecoder.convert (dart:convert\/json.dart:610)\n#4 JsonCodec.decode (dart:convert\/json.dart:216)\n#5 jsonDecode (dart:convert\/json.dart:155)\n#6 main (package:dispatch_email\/main.dart:23)\n#7 main.<anonymous closure>.<anonymous closure> (file:\/\/\/usr\/local\/server\/src\/server.dart:115)\n#8 _rootRun (dart:async\/zone.dart:1399)\n#9 _CustomZone.run (dart:async\/zone.dart:1301)\n#10 _runZoned (dart:async\/zone.dart:1804)\n#11 runZoned (dart:async\/zone.dart:1747)\n#12 main.<anonymous closure> (file:\/\/\/usr\/local\/server\/src\/server.dart:110)\n<asynchronous suspension>\n#13 handleRequest (package:shelf\/shelf_io.dart:138)\n<asynchronous suspension>\n",
When I console log the context.req.body (I am using Dart Runtime 3.0) It shows that the body is empty, that's why I am getting error trying to decode it.
I am trying to figure out what change in cURL format from 1.1.2 to 1.4.2 since it works on my previous implementation on 1.1.2
Here a post I've made about it: https://dev.to/williamcardoso/sending-emails-with-dart-and-appwrite-serverless-functions-3dmj
I am updating to 1.4.2

Gotch Try to send it like so
--data '{
\"data\": \"{\"

Meaning add \
to all double quotes

Still nothing :/ but thanks for your help

It is interesting that the same cURL works for mine 1.1.2 Appwrite Function

The problem is that your Dart function can't convert this json

I understand. But what is hapening is the body is not even reaching my function. It is going empty

When I validate the body, it states that it is empty. That's the error. The body is not properly going through curl.

I fixed. It is the same way as before, but, now it has changed to body

The Appwrite documentation does not state it anywhere. Very sad. I always get some frustration with such doc. I will try to open pr or issues later to get attention for it

Now that you said it You can see here the different https://appwrite.io/docs/client/functions?sdk=rest-default&v=1.4.x#functionsCreateExecution


thank you very much

It would be good to also address here some curl example. Idk if my suggestion is not adequate

[Solved] Empty Body on cURL Request

I've updated the title to solved

appwrite rocks!
Recommended threads
- Where is tensorflow support? 3.11 ML doe...
and if i manually tried to add tensorflow i get Cannot access offset of type string on string no matter what
- OAuth2 Error: invalid success param url ...
Hi everyone! I'm trying to implement Google OAuth2 login in a React Native app (using the Android simulator) with Appwrite Cloud, and I'm getting the following ...
- Trying to set up a new appwrite project
we have used the folder structure as follow Functions /function-name /src/index,js This is our entrypoint and git confugre settings When I try to run ...
