Can't locate object method "" via package "Mojo::UserAgent::Transactor"

142 views
Skip to first unread message

Todd

unread,
Jul 15, 2016, 12:54:10 PM7/15/16
to Mojolicious
Just upgraded Mojolicious to latest via cpanm 
Mojolicious-6.66 (upgraded from 6.38)

This line in my program worked before the upgrade:

$tx     = $ua->$verb($url => {Accept => '*/*'} => body => $newjson);

where in this case $verb is a post, and $newjson is a valid hash ref of data.

Now I get the following error message when I execute the line above:

Can't locate object method "" via package "Mojo::UserAgent::Transactor" at /usr/local/share/perl/5.18.2/Mojo/UserAgent/Transactor.pm line 118.

Looking at the docs, it doesn't appear the calling syntax has changed.  Looking at Transactor.pm we have:

116: if (@_ > 1) {
117:   my $cb = $self->generators->{shift()};
118:     $self->$cb($tx, @_);
119:  }

Any ideas why this is blowing up?  Let me know if you need additional information.

Todd

Dan Book

unread,
Jul 15, 2016, 1:10:31 PM7/15/16
to mojol...@googlegroups.com
There is no 'body' generator, only 'form' or 'json'. https://metacpan.org/pod/Mojo::UserAgent::Transactor#GENERATORS

Since you said $newjson is a hashref, you probably wanted the json generator.

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Todd

unread,
Jul 15, 2016, 1:28:25 PM7/15/16
to Mojolicious
Weird, there used to be a body because it worked in 6.38, and unfortunate, because I'm using that to proxy a request to an elasticsearch server and the js code (searchkit.js) does exactly that and switching to "form"or "json" confuses the ES server.

Back to the drawing board...

Dan Book

unread,
Jul 15, 2016, 2:31:32 PM7/15/16
to mojol...@googlegroups.com
If it worked before it was by accident. In 6.38 it would ignore any unrecognized generator. You can get that same behavior by just leaving out the 'body' parameter.

Todd

unread,
Jul 15, 2016, 3:50:56 PM7/15/16
to Mojolicious
Awesome, that worked.  Thanks for the help.
Reply all
Reply to author
Forward
0 new messages