in reply to Re: Invalid nonce
in thread Invalid nonce

thanks i have been able to fix this problem by generating nonce like this

my @Char = ('a'..'z'); my $Leng = 36; my $RandomChar = ''; for (1..$Leng) { $RandomChar .= $Char[int rand @Char]; }

Replies are listed 'Best First'.
Re^3: Invalid nonce
by bliako (Abbot) on Jul 19, 2024 at 16:49 UTC

    but Corion told you not to use rand(). because it is likely (in the case of 36char strings actually quite unlikely) that nonce will be the same. Why introduce bugs in your code? You can start with a nonce and keep incrementing it perhaps? my $startnonce = 'a' x 36; print $startnonce++."\n" for 1..10; (note that this will expand to invalid nonce of 37 characters long after some 26**36 nonces). Or append Time::HiRes::time() into a constant nonce part in order to complete 36 chars my $nonce = substr Time::HiRes::time().("a" x 36), 0, 36. This will fail if your two requests happen in the same nanosecond.

    minor edits after a few minutes

Re^3: Invalid nonce
by frank1 (Monk) on Jul 19, 2024 at 16:19 UTC

    am just having this error confusing me

    Error: {"status": "error", "reason": "Content-Type header should not be present", "code": "API0020"}

    and API says

    Content-Type header should not be present Please make sure you're not sending any body in the request.

    and when i remove "Content-Type" => 'application/x-www-form-urlencoded'

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

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

        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"}