简体   繁体   中英

HTTP POST request with Erlang

I am using the code below for sending an HTTP POST request, and it's not giving any error but I am not able to hit the server using this. Can anyone help me determine what could be the issue with this, or if I am missing something.

start() ->
    inets:start(),
    io:fwrite("inet started \n"),
    httpc:request(post, {"[http://api.myapp.com/apipush.php]", [],
                         "application/x-www-form-urlencoded", ""},[],[]),
    io:fwrite("req sent!\n").

I think you have some misplaced square brackets in your call to the server. Remove the [ and ] from around the URL, like this:

httpc:request(post, {"http://api.myapp.com/apipush.php", [],
                     "application/x-www-form-urlencoded", ""},[],[]),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM