bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

am trying to parse the error message but its not working i dont know why.

am making http post

my $Msg; my $resp = $ua->request($req); if ($resp->is_success) { my $Rep = JSON::XS->new->decode ($resp->decoded_content); $Msg = $Rep->{data}->{error_message}; } else { print "", $resp->decoded_content, "n"; } print "Error: $Msg\n";

and the response is

{ "status": "fail", "data": { "error_message": "Cannot withdraw funds +without Network Fee of 0.00000000 BTC. Maximum withdrawable balance i +s 0.00000000 BTC.", "available_balance": "0.00000000", "max_withdrawa +l_available": "0.00000000", "minimum_balance_needed": "0.00053590", " +coin_fee": "0.00000000", "estimated_network_fee": "0.00000000", "esti +mated_min_custom_network_fee": "0.00000000", "estimated_max_custom_ne +twork_fee": "0.00000000" } }nError:

so am trying to parse error message like this

$Msg = $Rep->{data}->{error_message};

but not working

Replies are listed 'Best First'.
Re: parsing json message
by hippo (Archbishop) on Feb 02, 2022 at 16:45 UTC

    $resp->is_success evaluates to false.


    🦛

      thanks, i never even think about this. it has worked