Can't post json in a Mojo::UserAgent request

mojo, mojolicious, perl

Solution

Are all of your boxes using Mojolicious 3.85 or greater? The UA `form`/`json` generators are very new, only since 3.85 or 2013-02-13.

Also you might try removing the empty hashref (which would be for extra headers), unless there is some reason to have it there.

Problem

I can't get the following `Mojo::UserAgent` call to post JSON to the server: ``` use Mojo::UserAgent; my $ua=Mojo::UserAgent->new; my $json = $ua->post("localhost:6767" => {} => json =>{ val=>10 })->res->json; ``` Using a fake debug server on the other side with `nc -l 6767` gives the following output: ``` POST / HTTP/1.1 User-Agent: Mojolicious (Perl) Connection: keep-alive Content-Length: 0 Host: localhost:6767 ``` It's not just the `json` method, the `form`, and the whole Transactor seems to be broken on 2 of my machines. From the docs: ``` perl -MMojo::UserAgent::Transactor -E 'say Mojo::UserAgent::Transactor->new->tx(PUT => "http://kraih.com" => json => {a => "b"})->req->to_string;' PUT / HTTP/1.1 Content-Length: 4 Host: kraih.com json ``` Hard to believe my eyes. What am I missing?

Original source