[Building Sakai] A note about POSTing data to EntityBroker

Aaron Zeckoski azeckoski at unicon.net
Fri Mar 23 05:29:59 PDT 2012


The JSON parse in EB is just a parsing the data it gets.

If you use application/x-www-form-urlencoded then it only sends the
name/value pairs in the body:
"For application/x-www-form-urlencoded, the body of the HTTP message
sent to the server is essentially one giant query string -- name/value
pairs are separated by the ampersand (&), and names are separated from
values by the equal symbal (=)."
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1

In other words, the content of the body (the JSON encoded object
string in this case) is not sent to the server at all. It is replaced
by encoded name/value pairs and in this case I think Steve had no
name/value pairs so the content was basically empty and the JSON data
lost.

Alternatively, multipart/form-data (or some content type which uses
it) will leave the "body" content as sent intact (though really it is
encoding the nam/value pairs and also that content into the actual
body of the request).
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2

I can't see how this could be fixed on the server side but I could be
mistaken here so I welcome any suggestions/patches.
:-)
-AZ



On Fri, Mar 23, 2012 at 7:21 AM, Steve Swinsburg
<steve.swinsburg at gmail.com> wrote:
> That's probably one for Aaron, it may be in the JSON parsing perhaps.
>
> Sent from my iPad
>
> On 23/03/2012, at 9:52 PM, Matthew Buckett <matthew.buckett at oucs.ox.ac.uk> wrote:
>
>> On 23 March 2012 00:00, Steve Swinsburg <steve.swinsburg at gmail.com> wrote:
>>> Hi all,
>>>
>>> I've just spent a considerable amount of time battling through an issue I
>>> had with POSTing data to EntityBroker, in order to create entities.
>>>
>>> To cut a long story short, you need to ensure the content type is being set
>>> correctly otherwise you will get unexpected results like the object being
>>> created but no data being populated.
>>>
>>>  In the case of JSON, it must be:
>>> application/json; charset=utf-8
>>
>> Is there a reason why from a design point of view it should fail with:
>> Content-Type: application/x-www-form-urlencoded ?
>>
>> To me this sounds like a bug in entity broker that should either
>> support additional content type or throw a nice error saying you need
>> to switch to a different content-type.
>>
>> --
>>   Matthew Buckett
>>   VLE Developer, LTG, Oxford University Computing Services



-- 
Aaron Zeckoski - Software Architect - http://tinyurl.com/azprofile


More information about the sakai-dev mailing list