A simple example of using Erlang for a https message

I found a quote from several examples of using erlang with ssl (via rpc) and http get, etc. But it's hard for me to find an example of sending data to an ssl endpoint via erlang. Does anyone know a simple example that I am missing?

I think I get it. I had the wrong arguments. This is what I ended up for publishing:

 httpc: request (post, {"https: // localhost: 2840", [], [], ["Test"]}, [], [])

Work appears. But now my server is crashing. So maybe not.

+8
erlang ssl
source share
1 answer

Before sending a request, you need to run ssl and inets. Depending on the type of data you are trying to publish, you need to format it differently. My example shows data with urlencoded

ssl:start(), application:start(inets), httpc:request(post, {"https://postman-echo.com/post", [], "application/x-www-form-urlencoded", "example=here&foo=bar" }, [], []). 

JSON request will look like

 ssl:start(), application:start(inets), httpc:request(post, {"https://postman-echo.com/post", [], "application/json", "{'example':'here', 'foo':'bar'}" }, [], []). 
+11
source

All Articles