[Building Sakai] A note about POSTing data to EntityBroker

Matthew Buckett matthew.buckett at oucs.ox.ac.uk
Mon Mar 26 01:59:52 PDT 2012


On 23 March 2012 12:29, Aaron Zeckoski <azeckoski at unicon.net> wrote:
> 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.

Just to make sure I understand correctly entitybroker decides which
parser to use based on the extension of the URL .xml = XML .json =
JSON?

So if the URL ends .json and the content type is
application/x-www-form-urlencoded  there is no sensible way it can
understand the request so would it be better off throwing an error say
you probably need to set your content type to application/json?

This might save future developers some frustration.

-- 
  Matthew Buckett
  VLE Developer, LTG, Oxford University Computing Services


More information about the sakai-dev mailing list