Erlang : Writing HTTP POST Request to external API with example

We can able to write HTTP Request in Erlang for external API callbacks. This can be achieved by calling function “httpc:request()”. This function sent HTTP request by constructing our input given in Parameter to the function.

Syntax:

httpc:request(METHOD,{"REQUEST_URL", [],"REQUEST HEADER",REQUEST_INPUT_DATA}, [], []).

Example:

IPAddress = '192.168.99.70',
Resourcename = 'mobile',
Servername = 'server1',
Username = 'CodeExpertz',
Userdata = "user=" ++ Username ++ "&resource=" ++ Resourcename ++ "&server=" ++ Servername ++ "&ipaddress=" ++ IPAddress,
httpc:request(post,{"http://192.168.99.35:8083/api/ejabberd/login", [], "application/x-www-form-urlencoded", Userdata}, [], []).
Category: