in reply to Re: 500 Not a SCALAR reference
in thread 500 Not a SCALAR reference

i have been doing some research on error i found out that You are missing the body of your request. A POST request is supposed to have the body first, and then the optional headers

Replies are listed 'Best First'.
Re^3: 500 Not a SCALAR reference
by stevieb (Canon) on Jan 07, 2019 at 22:19 UTC

    Is that the exact error message? Please copy and paste the *exact* error message into <code></code> tags within the Original Post.

    Also, where is use strict; and use warnings;? I've come to overlook posts without those pragmas present by people who should know better.

    -stevieb: Just Another Perl Monkey

        That explains a fair bit that does.

      i have updated it with strict and warning also added a clear header structure. you can see the output and the error i get

        See post

        #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use Digest::SHA qw(hmac_sha256_hex); use Time::HiRes qw(gettimeofday); use URI; use Encode; my $nonce = int (gettimeofday * 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/^[?]//; my $message = encode('utf8',$nonce.$hmac_key.$api_endpoint.$post_param +s_urlencoded); my $signature = uc hmac_sha256_hex($message, $hmac_secret); my %headers = ( 'Apiauth-Key' => $hmac_key, 'Apiauth-Nonce' => $nonce, 'Apiauth-Signature' => $signature, ); my $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); # remove exit to send request $ua->add_handler( request_prepare => sub { print "Request:\n".$_[0]->as_string; exit }); my $res = $ua->post( $url.$api_endpoint, %headers, Content => $post_pa +rams_urlencoded ); print "Content-type: text/plain\n\n"; if ($res->is_success) { print $res->content; } else { print $res->status_line; }
        poj