[dancer-users] The case of the missing body-parameter...

vijayvithal jahagirdar jahagirdar.vs at gmail.com
Wed Jul 5 19:03:14 BST 2017

I am debugging a dancer2 ajax application which receives a POST request as

wget --post-data '{"item":{"filename":"/prj/dyumnin/
designw.in/web/WS/log/Build_1/13RTL Compile Check.log"}}'

*My route definition is *

package api;
use Data::Dumper;
use Dancer2 appname=>'web';
use Dancer2::Plugin::Database;
use spreadsheet;
use Data::GUID::Any 'guid_as_string';
use Dancer2::Plugin::REST;
use File::ReadBackwards;

prefix '/api/prjEdit';

post '/getFileTail.:format'=>sub{
        my $data=body_parameters->get_all('item');
        debug Dumper $data;
        debug Dumper body_parameters;
         my %all_parameters = params;
        debug Dumper \%all_parameters;

*What I see in the log is*

[web:17548] core @2017-07-05 22:53:10> looking for post
/api/prjEdit/getFileTail.json in
/usr/local/share/perl/5.22.1/Dancer2/Core/App.pm l. 35
[web:17548] core @2017-07-05 22:53:10> Entering hook
core.app.before_request in (eval 258) l. 1
[web:17548] debug @2017-07-05 22:53:10> *$VAR1 = undef;* in /prj/dyumnin/
designw.in/web/bin/../lib/api.pm l. 211
[web:17548] debug @2017-07-05 22:53:10>* $VAR1 = bless( {},
'Hash::MultiValue' ); i*n /prj/dyumnin/designw.in/web/bin/../lib/api.pm l.
[web:17548] debug @2017-07-05 22:53:10>* $VAR1 = {*
*          'format' => 'json'*
*        }; *in /prj/dyumnin/designw.in/web/bin/../lib/api.pm l. 214

Similar requests for other routes work.I am unable to understand why the
body parameter is getting lost for this route. and Have not Idea where to
begin my search.
To make matters worst when coupled with the Angular2 front end. for the
same request sometimes the body parameters are passed to this route and
sometimes they are not.

Any Hints on how to debug this scenario is welcome.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20170705/2ae8aa99/attachment.html>

More information about the dancer-users mailing list