我正在尝试使用Erlang将数据发布到我的webservice,但是这段代码没有编译并抛出错误:
calling** exception exit: {noproc,
{gen_server,call,
[httpc_manager,
{request,
{request,undefined,<0.107.0>,0,https,
{"url.com",443},
"/index.php/apipush/",[],post,
{http_request_h,undefined,"keep-alive",undefined,
undefined,undefined,undefined,undefined,undefined,
undefined,...},
{"application/x-www-form-urlencoded",
["from=Url","&",
"to=Url","&",
"body=is this working ?","&",
[...]|...]},
{http_options,"HTTP/1.1",infinity,true,
{essl,[]},
undefined,false,infinity,...},
"https://url",
[],none,[],1524639132571,undefined,undefined,
undefined,...}},
infinity]}}
in function gen_server:call/3 (gen_server.erl, line 214)
in call from httpc:handle_request/9 (httpc.erl, line 557)
in call from helloworld:start/0
我的代码是:
-module(helloworld).
-export([start/0]).
start() ->
io:format("calling"),
PostUrl = "host.com",
Sep = "&",
PostStatic = [
"from=dd@host.com", Sep,
"to=aaa@host.com", Sep,
"body=is this working ?"
],
httpc:request(post, {PostUrl, [], "application/x-www-form-urlencoded", PostStatic}, [], []),
io:format("called").
请帮我解决代码有什么问题。解释将是可观的。 P.S:Erlang的新手
答案 0 :(得分:3)
您需要在致电inets
之前启动httpc:request
应用程序:
inets:start().