[erlang-questions] Re: sending a json body with http:request
Fri Jan 29 00:56:25 CET 2010
It works but there is probably a better way.
You are right about mixing form encoding and json.
From: Tim Fletcher <twoggle@REDACTED>
Sent: Fri, January 29, 2010 12:55:25 AM
Subject: [erlang-questions] Re: sending a json body with http:request
> mochijson2:encode/1 returns binary so do I need to use binary_to_list on it?
I think mochijson2:encode/1 returns an iolist, not a binary. You can
use the iolist_to_binary function to convert to binary.
> Do I need to url encode the Params?
If you're sending content as "application/x-www-form-urlencoded", then
it should be encoded appropriately:
Note that this is different to the URI encoding defined in RFC 3986.
> Is there a url encoding function in erlang other then edoc_lib:escape_uri/1?
AFAIK, no. That doesn't appear to encode as application/x-www-form-
I put together a comparison of several different encoding
Is there a reason the server expects a mixture of JSON *and* form
urlencoded params? Surely it would be easier to just send a JSON
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org
More information about the erlang-questions