iamacube

iamacube

1st argument: not an iodata term Error For multilingual text

I am trying to send a string of text as a body like this:

HTTPoison.post(
      "https://api.letter.net",
      '{"text": "{🇺🇸 : Hello #{message} welcome here #{number} \n 🇯🇵 : #{number} ようこそいらっしゃいました #{message} ハローウェルカム\n 🇰🇷 : #{message} 안녕 #{number} 여기 오신 것을 환영합니다}"}',
      [{"Content-Type", "application/json"}]
    )

But I am getting this error

[error] GenServer #PID<0.780.0> terminating
** (ArgumentError) errors were found at the given arguments:

  * 1st argument: not an iodata term

    :erlang.iolist_to_binary([123, 34, 116, 101, 120, 116, 34, 58, 32, 34, 127482, 127480, 32, 58, 32, 65, 32, 110, 101, 119, 32, 114, 101, 108, 101, 97, 115, 101, 32, 110, 111, 116, 101, 115, 32, 102, 111, 114, 32, 118, 51, 46, 49, 50, 46, 48, 32, 114, 101, 108, ...])

I know that this is because of the Japanese and Korean text but I am I did not find resources on how to send something like this…

Marked As Solved

LostKobrakai

LostKobrakai

Single quotes cannot be used interchangably with double quotes in elixir. Single quotes are a used for charlists and double quotes are use for binaries, which are different datatypes.

There are a few ways to go about double quotes within binaries.

# Escape inner quotes
"{\"text\": …"

# Use sigil_s to have different delimiters for a binary
~s({"text": …)

# Don't deal with json manually and use a json library like jason to do the encoding
Jason.encode!(%{text: """
{🇺🇸 : Hello #{message} welcome here #{number} 
 🇯🇵 : #{number} ようこそいらっしゃいました #{message} ハローウェルカム
 🇰🇷 : #{message} 안녕 #{number} 여기 오신 것을 환영합니다}
"""})

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

Other popular topics Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement