Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

curl post

by bigup401 (Pilgrim)
on Oct 23, 2017 at 12:27 UTC ( [id://1201880]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1201880]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-24 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found