2

I am having an issue when send Http request to Infobip SMS APi with Unicode character in body. I tried with axios and request module but both are not working for unicode value but it's working for normal english character. here is the code

var express = require('express');
var request = require('request');
var app = express();

var url = 'http://api.infobip.com/sms/2/text/single'
var options = {
    method: 'post',
    data: {
      'from': 'ME',
      'to': '(555) 555-1234',
      'text': 'ওহে বিশ্ব',
    },
    headers: {
      'authorization': 'Basic AUTH_KEY',
      'content-type': 'application/json',
      'accept': 'application/json'
    },
    url: url
}
request(options, function (err, res, body) {
  if (err) {
    console.log('Error', err);

  }
  console.log(res, body);

})
msmolcic
  • 6,407
  • 8
  • 32
  • 56
naimjeem
  • 657
  • 6
  • 7

1 Answers1

1

you can check it by axios

var express = require('express');
var app = express();

var axios = require("axios");

const config = 
    { 
     headers: 
         {   
         'authorization': 'Basic AUTH_ID',
         'content-type': 'application/json;charset=UTF-8',
         'accept': 'application/json' 
         } 
    };

 axios.post('http://api.infobip.com/sms/2/text/single',

     {
      'from': 'ME',
      'to': '+8801XXXXXX',
      'text': 'ওহে বিশ্ব',    
     },
     config,
 )
.then(function(response) {
     console.log(response.data)
 })
.catch(function(error) {
     console.log(error)
 })