Problem using the post method (httposion)

I have a problem using the post method of
“httposion”, could help me?

This command worked perfectly
curl -X POST --data '{"name":"test.com.", "kind": "Native", "masters": [], "nameservers": ["test1.com.", "test2.com"]}' -v -H 'X-API-Key: mykey' http://127.0.0.1:8081/api/v1/servers/localhost/zones | jq .

But when I will use “httpoison”, it returns an error

  url = "http://127.0.0.1:8081" <> "/api/v1/servers/localhost"
  headers = [{"X-API-Key",  "mykey"}]
  body = {:multipart, [
    {"name", "test.com."}, 
    {"kind", "Native"}, 
    {"masters", "[]"}, 
    {"nameservers", [{"test1.com.", "test2.com"}]}
                      ]
          }
HTTPoison.post(url, body, headers)

Error generated:

** (FunctionClauseError) no function clause matching in anonymous fn/2 in :hackney_multipart.len_mp_stream/2

The following arguments were given to anonymous fn/2 in :hackney_multipart.len_mp_stream/2:

    # 1
    {"nameservers", [{"test1.com.", "test2.com"}]}

    # 2
    496

(hackney) /deps/hackney/src/hackney_multipart.erl:168: anonymous fn/2 in :hackney_multipart.len_mp_stream/2
(stdlib) lists.erl:1263: :lists.foldl/3
(hackney) /deps/hackney/src/hackney_multipart.erl:168: :hackney_multipart.len_mp_stream/2
(hackney) /deps/hackney/src/hackney_request.erl:323: :hackney_request.handle_body/4
(hackney) /deps/hackney/src/hackney_request.erl:83: :hackney_request.perform/2
(hackney) /deps/hackney/src/hackney.erl:376: :hackney.send_request/2
(httpoison) lib/httpoison/base.ex:796: HTTPoison.Base.request/6

How do I make it work?

Multipart takes a list of tuples, where both elements are binaries.

One the name of the part, the other the contents.

Also the requests aren’t equivalent.

The curl seems to send a single JSON payload, while the elixir code sends a multipart request with multiple payloads.