Snippet from the test:
my $request = HTTP::Request->new( POST => 'http://192.168.5.130:3000/user' );
$request->content_type('application/json');
$request->content( $query_string );
my $result = $ua->request( $request );
Snippet from the ajax call:
$.ajax({
url: 'http://192.168.5.130:3000/user',
type: 'POST',
cache: false,
async: true,
dataType: 'json',
timeout: 5000,
data: $("#create-user-form").serializeObject(),
error: function(jqXHR, textStatus, errorThrown){
console.log("jQuery ajax error....");
},
);
In the controller is the route handler (using Catalyst::Controller::Rest
)
sub user_POST {
my ($self, $c, $args) = @_;
warn Dumper( $c );
...
}
The problem I'm having is, when I make the call from the test the content is
set in the Catalyst object in a hash with a key called 'data' which can be
accessed be calling $c->req->data
.
However, when the ajax call is made from a webpage, the data is
held in the Catalyst object in a hash with a key called 'parameters' which is
accessed by calling $c->req->parameters
.
Anyone know why this is happening and or what to do to work around it?