In an effort to stop my wall from getting a bigger hole in it from my head, I post this question.. In the below code, I am posting HTTPS to a server with both headers and name/value pairs. I cannot for the life of me, get the headers to go in any way shaped or form. If I try to send the headers via "$headers (using HTTP::Headers), I get the error: Not an ARRAY reference at C:/Perl/lib/HTTP/Request/Common.pm line 82. Ok, so I change it to an array using @headers, no error this time, however, the name/value pairs do not get submitted along with the post, so I get errors in the response. If I remove the @headers from the POST line, I get the correct reponse from the server, but, of course I did not send any headers. Please help!!
#!/ActivePerl-.10/bin/perl use LWP 5.69; use HTTP::Request::Common qw( POST ); use HTTP::Headers; use HTTP::Response; my $submit_values = { #name/value pairs here + }; + + my $headers = HTTP::Headers->new( + 'Timeout' => '30', + ); + my @headers = ( + 'Timeout','30', + ); + my $ua = LWP::UserAgent->new( protocols_allowed => ['https'] ); + my $r = POST( 'https://someserver.com',@headers,$submit_values); + my $myresponse = $ua->request( $r ); $apiresponse = $myresponse->content ; print $apiresponse; exit;

In reply to LWP: POST with headers by tbbatccc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.