[Catalyst] deserializing key value pairs Catalyst::Controller::REST

Hani Anani hanianani at gmail.com
Fri Jul 25 06:12:09 BST 2008


I am having trouble getting deserialize to work correctly in the REST
interface that i am building out.

Here's the info:

the debug message i get when running the catalyst server prints out:

[debug] I would have deserialized, but there was nothing in the body!

looks like nothing is returned in the call made by the REST JSON plugin

line 34 $c->request->body

but also in the debug log is the following:

[debug] Body Parameters are:

| Parameter                           | Value                              =
| destination_account                 | 2                                  =

| ingestor_id                         | 10                                 =
| source_account                      | 1                                  =
| source_id                           | 1                                  =


Here's the javascript that submits the request:

var sUrl =3D "/rest/db/source_destination_map/";
var postData =3D "source_account=3D1&destination_account=3D2&ingestor_id=3D=

function makeRequest(){
    YAHOO.util.Connect.initHeader('Content-Type', 'application/json', null);
'd72fc6813c5618876309e3f8cbc7b741', null);

    var request =3D YAHOO.util.Connect.asyncRequest('POST', sUrl,
callback, postData);

    YAHOO.log("Initiating request; tId: " + request.tId + ".", "info",


and trying to access $c->request->data in my REST

here's the begin:

sub begin : ActionClass('Deserialize') {
    my ($self, $c) =3D @_;

    if ( $self->_auth_private_web_service( $c ) ){

        $c->res->body("You are not authorized to use the private REST API."=

and the method:

sub source_destination_map_POST {
    my ($self, $c) =3D @_;

    my ( $source_destination_map, $source_ingestor_destination_map );

    my @params =3D %{$c->request->params};

    my $l =3D $c->request->body;

    print STDERR "BODY " . Dumper $l;


returns the following:

BODY $VAR1 =3D undef;

So, I can see that the request object also has the body_params method
which I am guessing is where the key value pairs of the parameters is
being passed, but the JSON deserializer
seems to try to retrieve it from $c->request->body,

As a result attempting to access things via $c->request->data in my
source_destination_map_POST method does not work.

many thanks for looking at this,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080724/ee635=

More information about the Catalyst mailing list