Hi everyone,
I'm using an api to send messages but the problem is that when I insert an emoji in the body I get a 400 Bad request back here is my js code :
var jsonData = {
"type": "text",
"text": "body": "hello how are you ",
token = "xxxxxxxxxxx",
contentType = "application/json";
var req = new HttpClientRequest('https://exampleTestEndpoint.com/sendMessage/128192');
req.header["Authorization"] = token;
req.header["Content-Type"] = contentType;
req.method = "POST";
var data = jsonData;
req.body = JSON.stringify(data);
req.execute();
var resp = req.response;
var code = resp.code;
var body = JSON.parse(resp.body);
Then when I remove the emoji everything works normally, I tried with another api from another service and I had the same problem when I insert an emoji,
I also tried with the utf-8 code of the emoji but it still doesn't work.
Thank you in advance for your help!
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hello everyone,
I've found the solution to the problem, which was to change the encoding in the header and replace this value in the header
var contentType = "application/json;charset=UTF-8";
req.header["Content-Type"] = contentType;
most modules take it into account automatically, but on adobe campaign you have to specify it.
Views
Replies
Total Likes
HI @AnasSpir05
I would suppose you need to send the emojis in their unicode value. Emojis are unique code values and JSON is using unicode too,
This page is old https://stackoverflow.com/questions/7177808/emoji-characters-cannot-be-encoded-to-json#:~:text=If%20.... and it seems that there are a few tricks to put emojis in JSON
Now how to get unicode for a emojis, I don't now exactly and you certainly can find the how by search internet (Stackoverflow or other)
Thanks
Denis
Hello everyone,
I've found the solution to the problem, which was to change the encoding in the header and replace this value in the header
var contentType = "application/json;charset=UTF-8";
req.header["Content-Type"] = contentType;
most modules take it into account automatically, but on adobe campaign you have to specify it.
Views
Replies
Total Likes
Views
Likes
Replies