Re: Accessing application/json message body of POST request
Bardo Nelgen <[email protected]> Mon, 17 Mar 2014 18:21:53 +0100
| Newsgroups | gmane.text.xml.cocoon.user |
|---|---|
| Organization | BNN Performances |
| Message-ID | <[email protected]> |
Hi Warrell,
thanks for the input.
Though our problem actually isn't *processing* the JSON, but initially
getting it out of a POST request's application/json message body at all.
If the JSON is postet wwwform-urlencoded and comes with common
variable-value pairs, indeed a variety of options exists.
If, however, one cannot even destill the payload itself out of the
request, the largest variety of processing options is not of much help.
What I get is more something like this
> POST /serviceendpoint/ HTTP/1.1
>
> Host: mydomain.com
>
> Authorization: MyAuthKeyHere
>
> Accept-Encoding: gzip, deflate
>
> Content-Type: application/json // this is the identified reason, why
> Cocoon stops processing before the message body
>
> Accept-Language: en-us
>
> Accept: */*
>
> Content-Length: 80
>
> Connection: keep-alive
>
> User-Agent: proprietaryUA
>
> {"jsonPayload":"verylongpayloadcontentcangohereifyoulike"}
Nonetheless, thanks for all of your suggestions; will get back to these
lateron for sure...
Best,
Bardo
On 16.03.14 23.00 Uhr, warrell harries wrote:
>
> Hi Bardo,
>
> The simplest way that I have found to handle json posts is to use the
> text generator. Alternatively, you are free to write a json generator
> which would convert json to xml as this is the default data format of
> cocoon. I have been successfuly using cocoon to handle json (the
> contemporary data format of choice) for a few years now. Very recently
> I have been using cocoon as middleware between a datasource and Cube.
> This Node.js app front ends mongodb using json as the transport over
> http. Cocoon still rocks in this new world. Please get in touch if
> there is anything I can help with. Best regards Warrell
>
> On 16 Mar 2014 19:37, "Bardo Nelgen"
> <[email protected]
> <mailto:[email protected]>> wrote:
>
>
> Hi all,
>
> has someone ever accessed the message body of a post request to
> cocoon which uses application/json as its content type?
>
> The same request is being handled without issues if posted as
> application/x-www-form-urlencoded.
>
> Though, as soon as the content type is changed to JSON, Cocoon
> appears to skip parsing the message body.
>
> Unfortunately it's not me making these POST calls; which is why
> just "switching it" is not an option.
>
> Is there some setting which can tell cocoon to simply continue
> parsing, either regardless of a post's content type (which, of
> course might raise security issues...) or explicitly for
> application/json ?
>
> Any suggestions are welcome.
>
> Regards,
>
> Bardo
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> <mailto:[email protected]>
> For additional commands, e-mail: [email protected]
> <mailto:[email protected]>
>