thanks to poj who helped me on this 400 BAD REQUEST to structure the request. then I came up with header structure and body structure. now am trying to make the request but am getting 500 Not a SCALAR reference

#!/usr/bin/perl use strict; use warnings; use HTTP::Request::Common qw(POST); use LWP::UserAgent; use Digest::SHA qw(hmac_sha256_hex); use URI; use Encode; use HTTP::Headers; use HTTP::Message; my $nonce = 1000; my $url = "https://localbitcoins.com"; my $api_endpoint = "/api/merchant/new_invoice/"; my $hmac_key = "sdfsdfdsfdsfy"; my $hmac_secret = "sdfdsfdsf"; my %params = ( currency => 'USD', amount => '500', description => 'HEY', internal => '0', ); my $uri = URI->new(); $uri->query_form( \%params ); my $post_params_urlencoded = $uri->as_string; $post_params_urlencoded =~ s/^[?]//; printf "params = %s\n", $post_params_urlencoded; my $message = encode('utf8',$nonce.$hmac_key.$api_endpoint.$post_p +arams_urlencoded); my $signature = uc hmac_sha256_hex($message, $hmac_secret); printf "sig = %s\n",$signature; print"\n"; print "headers are:\n"; my $headers = HTTP::Headers->new( 'Apiauth-Key' => $hmac_key, 'Apiauth-Nonce' => $nonce, 'Apiauth-Signature' => $signature, ); my $body = HTTP::Message->new($headers, $post_params_urlencoded); print $body->as_string; my $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); my $req = HTTP::Request->new(POST => $url); $req->content($body); my $res = $ua->request($req); print "Content-type: text/plain\n\n"; if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; }

Output

params = currency=USD&amount=500&internal=0&description=HEY sig = FE5B4A4A66FEAB0C1216B59C81BC2FD2CA5DC4459D84CF9A7DD8EFE37242E59A headers are: Apiauth-Key: sdfsdfdsfdsfy Apiauth-Nonce: 1000 Apiauth-Signature: FE5B4A4A66FEAB0C1216B59C81BC2FD2CA5DC4459D84CF9A7DD +8EFE37242E 59A currency=USD&amount=500&internal=0&description=HEY Content-type: text/plain 500 Not a SCALAR reference Press any key to continue . . .

In reply to 500 Not a SCALAR reference by bigup401

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.