sending a json body with http:request

Pablo Platt pablo.platt@REDACTED
Thu Jan 28 22:18:42 CET 2010


Hi,

I'm using mochijson2 to encode json and I need to send it with an http request.
I'm using
SampleData = [<<"a">>, <<"b">>],
Data = mochijson2:encode(SampleData),
Params = lists:append(["param1=", Data]),
URL = "http://localhost/path/",
http:request(post, {
            URL, [],
            "application/x-www-form-urlencoded",
            Params
        }, [], []).

mochijson2:encode/1 returns binary so do I need to use binary_to_list on it?
Do I need to url encode the Params?
Is there a url encoding function in erlang other then edoc_lib:escape_uri/1?

Thanks



      


More information about the erlang-questions mailing list