HTTPOISON - insert body parameters in elixir
<p>I'm trying to do a http request</p>

<pre><code>def getPage() do
    url = "http://myurl"
    body = '{
              "call": "MyCall",
              "app_key": "3347249693",
              "param": [
                  {
                      "page"          : 1,
                      "registres"     : 100,
                      "filter"        : "N"
                  }
              ]
             }'

    headers = [{"Content-type", "application/json"}]
    HTTPoison.post(url, body, headers, [])
end
</code></pre>

<p>this works for me well. </p>

<p>my question is - how can I insert variables in the body request.
meaning:</p>

<pre><code> def getPage(key, page, registers, filter) do
    url = "http://myurl"
    body = '{
              "call": "MyCall",
              "app_key": key,
              "param": [
                  {
                      "page"          : page,
                      "registres"     : registers,
                      "filter"        : filter
                  }
              ]
             }'

    headers = [{"Content-type", "application/json"}]
    HTTPoison.post(url, body, headers, [])
end
</code></pre>

<p>when I run it I get   </p>

<pre><code>%HTTPoison.Response{body: "\nFatal error: Uncaught exception 'Exception' with message 'Invalid JSON object' in /myurl/www/myurl_app/api/lib/php-wsdl/class.phpwsdl.servers.php:...
</code></pre>

<p>any suggestions?</p>