bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

HTTP Error 411. The request must be chunked or have a content length.

my $sender = $cgi->param('sender'); my $nums = $cgi->param('nums'); my $msg = $cgi->param('msg'); my $url = "link"; if ($sender, $nums && $msg) { my $json = encode_json { username => 'D2028', password => '8AEBC', "'{ \"to\": $nums, \"from\": \"$sender\" \"message\": \"$msg\" }'" }}; my $response = $http->post( $url => { content => $json, headers => { 'Content-Type' => 'application/json' }, }); $res = $response->{'content'};

this is the api

curl -X "POST" http://link -H 'username: tttt' -H 'password: ttt' -H " +Content-Type: application/json" -d '{"to": "444444","from":"Reach","m +essage":"cURL Message"}'

Replies are listed 'Best First'.
Re: curl post
by ikegami (Patriarch) on Oct 23, 2017 at 16:08 UTC
    my $json = encode_json({ to => $nums, from => $sender, message => $msg, }); my $response = $ua->post($url, Content_Type => 'application/json', username => $username, password => $password, Content => $json, });
Re: curl post
by Anonymous Monk on Oct 23, 2017 at 12:39 UTC
    What is the code? Why does encode_json get odd number of args?

      got it fixed