in reply to Re^3: Invalid nonce
in thread Invalid nonce

Their API documentation is very specific, the code you posted doesn't match their signature definition.

Replies are listed 'Best First'.
Re^5: Invalid nonce
by frank1 (Monk) on Jul 19, 2024 at 17:07 UTC

    Content-Type should not be added to the string if request.body is empty.

    but when i remove Content-Type, am getting this error Error: {"status": "error", "reason": "Invalid signature", "code": "API0005"}

      Have you checked that the string you construct for the signature is actually as the documentation says?

      You interpolate %params into the string, but you don't specify the order of the keys.

      My hint is to print out the string before you compute the mac for it, and manually compare the string with what the documentation says.

      "The following have to be combined into a single string:" which you don't.

        i have tried to do this

        my $apiKey = 'BITSTAMP pEF7aWa'; my $apiSecret = 'sWNuYX4QS'; my $urlcb = "https://www.bitstamp.net"; my $url = URI->new($urlcb); my $urlpath = $url->path('/api/v2/usdt_withdrawal/'); my @Char = ('a'..'z'); my $Leng = 36; my $RandomChar = ''; for (1..$Leng) { $RandomChar .= $Char[int rand @Char]; } my $timestamp = int (gettimeofday * 1000); my $nonce = $RandomChar; my $Query = URI->new(); $Query->query_form( 'currency' => "USDT", 'network' => "ethereum", 'address' => "#wallet", 'amount' => "4" ); my $API_Version = 'v2'; my $ContentType = "application/x-www-form-urlencoded"; my $signature = hmac_sha256_hex($apiKey.'POST'.$urlcb.$urlpath.$Conten +tType.$nonce.$timestamp.$API_Version.$Query, $apiSecret); my %payload = ( "X-Auth" => $apiKey, "X-Auth-Signature" => $signature, "X-Auth-Nonce" => $nonce, "X-Auth-Timestamp" => $timestamp, "X-Auth-Version" => $API_Version, "Content-Type" => $ContentType ); print $Query; print $signature;

        but am still getting this error

        Error: {"status": "error", "reason": "Invalid signature", "code": "API0005"}

        i have even tried to follow the API example in other Languages https://www.bitstamp.net/api/#section/Authentication/Authentication-examples