Home > Back-end >  How to send sms to user using msg91 in flutter?
How to send sms to user using msg91 in flutter?

Time:05-24

I have written the api call like this:

 var response = await http.post(
  Uri.parse("http://api.msg91.com/api/v2/sendsms"),
  headers: {
    "Content-Type": "application/json",
    "authkey": "API key"
  },
  body: jsonEncode({
    "sender": "note",
    "route": "4",
    "country": "91",
    "flash": 1,
    "sms": 
      {"message": "Message1", "to": "9999999999"}
  }),
);

But this giving me error : {type: error, message: Invalid content type.Please send data in formdata,application/xml,application/json format, code: }

How can I correct this?

CodePudding user response:

Try removing theses

"Content-Type": "application/json"

or replace it with

"Content-Type": "application/xml"

CodePudding user response:

You should use multipart/form-data as content-type ->

"Content-Type": "multipart/form-data"
  • Related