我有一个来自 api 的 curl 命令示例:
curl -sd '{"inputs":[{"addresses": ["add42af7dd58b27e1e6ca5c4fdc01214b52d382f"]}],"outputs":[{"addresses": ["884bae20ee442a1d53a1d44b1067af42f896e541"], "value": 4200000000000000}]}' https://api.blockcypher.com/v1/eth/main/txs/new?token=YOURTOKEN
我不知道如何将其转换为 Elixir 的 HTTPoison。我已经尝试了几个小时。我什至不能开始提及我经历过的所有迭代,但这就是我现在所处的位置:
Connect.post( "https://api.blockcypher.com/v1/eth/main/txs/new?token=#{@token}",
"",
[
{ "inputs", "{addresses, #{address_from}}"},
{ "outputs", "[{addresses, #{address_to}}, {value, #{eth_amount}}]"}
]
)
与我之前尝试过的大多数事情不同,它实际上到达了他们的服务器并给出了响应:
"{\"error\": \"Couldn't deserialize request: EOF\"}"
%{"error" => "Couldn't deserialize request: EOF"}
** (FunctionClauseError) no function clause matching in Base.encode16/2
(elixir) lib/base.ex:175: Base.encode16(nil, [])
(blockcypher) lib/blockcypher/handler.ex:55: Blockcypher.Handler.post_transa
ction_new/4
iex(46)>
你能帮我吗?我尝试将数据放在正文部分而不是标题中,但没有运气。