am getting this error when i try to run the code

"message":"invalid timestamp"

and this is the api timestamp guidelines

TIMESTAMPS All timestamp are returned in ISO8601 format in UTC with fields ending in postfix _at. Example: "created_at": "2015-07-01T00:55:47Z" Your timestamp must be within 30 seconds of the api service time or your request will be considered expired and rejected. We recommend using the time endpoint to query for the API server time if you believe there many be time skew between your server and the API servers. The CB-ACCESS-TIMESTAMP header MUST be number of seconds since Unix Epoch.

#!/usr/bin/perl use LWP::UserAgent; use JSON::Create 'create_json'; use JSON; use Digest::SHA qw(hmac_sha256_base64 hmac_sha256_hex hmac_sha256); use MIME::Base64; use POSIX qw(strftime); my $Endpoint = 'https://api.coinbase.com'; my $api_key = 'KEY'; my $secret = 'SCRETE'; my %json = ( type => 'send', to => 'ADDY', amount => '1.00', amount => 'USD' ); my $body = create_json (\%json); my $timestamp = strftime '%Y-%m-%dT%H:%M:%SZ', gmtime(); my $request_method = "POST"; my $request_path = '/v2/accounts/account:id/transactions'; my $message = $timestamp . $request_method . $request_path . $b +ody; my $decoded_secret = decode_base64($secret); my $signature_b64 = encode_base64( hmac_sha256($message, $decoded_secr +et) ); my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, ); $ua->agent("MyApp/0.1"); my $res = $ua->post( "$Endpoint$request_path", 'CB-ACCESS-SIGN' => $signature_b64, 'CB-ACCESS-TIMESTAMP' => $timestamp, 'CB-ACCESS-KEY' => $api_key, 'CB-ACCESS-VERSION' => '2019-11-15', 'Content-Type' => 'application/json' ); if ($res->is_success) { print $res->decoded_content; } else { print "request failed."; print "status:", $res->decoded_content; }

In reply to invalid timestamp 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.