in reply to Re^10: Invalid nonce
in thread Invalid nonce
i have been able to make this API to work, and am successfully interacting with it now
Am trying to make a post with this data
my $url_query = "currency=usdt"."&amount=20"."&address=0x55Dc816924e33 +CA50830A"."&destination_tag=None";
but am getting this error
API Documentation Section : https://www.bitstamp.net/api/#tag/Withdrawals/operation/RequestCryptoWithdrawal{"status": "error", "reason": {"amount": ["This field is required."]}}
Full code
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use Digest::SHA qw(hmac_sha256_hex); use UUID::Tiny ':std'; use URI::Escape; use JSON; use Time::HiRes qw(time); use JSON::XS; sub write_call_back { my ($data, $userp) = @_; ${$userp} .= $data; return length($data); } sub url_encode { my ($data) = @_; return uri_escape($data); } my $api_key = "api_key"; my $api_secret = "api_secret"; my $timestamp = int(time() * 1000); my $nonce = create_uuid_as_string(UUID_V4); my $x_auth = "BITSTAMP $api_key"; my $x_auth_nonce = $nonce; my $x_auth_timestamp = $timestamp; my $x_auth_version = "v2"; my $content_type = "application/x-www-form-urlencoded"; my $payload = url_encode('{"offset":1}'); my $http_method = "POST"; my $url_host = "www.bitstamp.net"; my $url_path = "/api/v2/usdt_withdrawal/?"; my $url_query = "currency=usdt"."&amount=20"."&address=0x55Dc816924e33 +CA50830A"."&destination_tag=None"; my $data_to_sign = join('', $x_auth, $http_method, $url_host, $url_path, $url_query, $content_type, $x_auth_nonce, $x_auth_timestamp, $x_auth_version, +$payload ); my $x_auth_signature = hmac_sha256_hex($data_to_sign, $api_secret); my $ua = LWP::UserAgent->new; my $url = "https://$url_host$url_path$url_query"; my $req = HTTP::Request->new(POST => $url); $req->header('X-Auth' => $x_auth); $req->header('X-Auth-Signature' => $x_auth_signature); $req->header('X-Auth-Nonce' => $x_auth_nonce); $req->header('X-Auth-Timestamp' => $x_auth_timestamp); $req->header('X-Auth-Version' => $x_auth_version); $req->header('Content-Type' => $content_type); $req->content($payload); my $resp = $ua->request($req); if ($resp->is_success) { print $resp->content; } else { print "HTTP POST error code: ", $resp->code, "\n"; print "HTTP POST error message: ", $resp->message, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^12: Invalid nonce
by hippo (Archbishop) on Aug 21, 2024 at 10:28 UTC | |
|
Re^12: Invalid nonce
by Corion (Patriarch) on Aug 21, 2024 at 16:12 UTC | |
|
Re^12: Invalid nonce
by cavac (Prior) on Aug 21, 2024 at 06:19 UTC | |
by frank1 (Monk) on Aug 21, 2024 at 12:45 UTC |