[erlang-questions] Posting HTTP Form Data with Erlang

Tino Breddin tino.breddin@REDACTED
Wed Aug 18 08:11:07 CEST 2010


Something like the following might work for you as well:

httpc:request(post, {Url, [], "application/x-www-form-urlencoded, "key=value&key2=value2}, [], []).

If required you could use edoc:escape_uri(String) for the individual values.

Be sure to start inets before using httpc.

Tino

On Aug 17, 2010, at 6:46 PM, Robert Raschke wrote:

> On Tue, Aug 17, 2010 at 4:43 PM, Rick Moynihan <rick@REDACTED> wrote:
> 
>> Does anyone know if there is an API that I can use to post HTTP form data?
>> 
>> I've looked at using inets:httpc, and it seems to have everything I
>> need, except that it doesn't appear to allow you to pass it a list of
>> key/value tuples and have them be encoded into the HTTP request as
>> application/x-www-form-urlencoded data.
>> 
>> Does anyone know if inets:httpc can do this, and if not whether there
>> are any libraries I can easily use?
>> 
>> 
> Mochiweb provides a Request "object" to your callback function, and that has
> a parse_post/0 function, which'll give you back a proplist of key/value
> pairs from your POST body (and you can use parse_qs/0 for GET options after
> the ? on the url).
> 
> Haven't used inets in a while.
> 
> Robby



More information about the erlang-questions mailing list