rohit-chouhan / whatsapp

A package for whatsapp business api, send messages, product, media, location through flutter app.
https://pub.dev/packages/whatsapp
MIT License
25 stars 18 forks source link

messagesText function returns false, fix key 'previewUrl' to 'preview_url' #4

Closed JoseAndresCartuche closed 2 years ago

JoseAndresCartuche commented 2 years ago

I was testing your flutter package, and sending a simple message with the messagesText function always returned false. I did the test with Postman, sending the json that is sent with the messagesText function, and I got an error (Status 400).

image

As you can see, the message says Unexpected key 'previewUrl'. I read the Whatsapp Api Documentation and it says that the correct key inside the text object is "preview_url".

I changed the 'previewUrl' key to 'preview_url' and did the test with Postman, and I got the whatsapp message to my phone number.

image image

So I corrected the key previewUrl to preview_url in the messagesText function, in my proyect.

Map data = {
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "$to",
  "type": "text",
  "text": {"preview_url": previewUrl, "body": "$message"}
};

And when using the function, the WhatsApp message is already sent and returns true.

I hope that you correct the key previewUrl, so that others who use your whatsapp package for flutter do not have the same problem.

rohit-chouhan commented 2 years ago

Thanks Jose, for the report! Now we have modified property from previewurl to preview_url in version 1.0.7