Невозможно опубликовать данные в веб-сервисе с помощью erlang httpc: request - PullRequest
0 голосов
/ 25 апреля 2018

Я пытаюсь отправить данные на мой веб-сервис, используя Erlang, но этот код не компилируется и выдает ошибку:

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

1 Ответ

0 голосов
/ 25 апреля 2018

Вам необходимо запустить приложение inets перед вызовом httpc:request:

inets:start().
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...