I started facing issue with one of our perl script which was working fine till last month. Can someone help me with this?
malformed JSON string, neither array, object, number, string or atom, at character offset 0
(before "<!doctype html><html...") at ad_lib.pm line 985.
and below is my line
my $response = from_json(qx{$BASE_HASH{CURL} -X GET -H "Content-Type: application/json" -H "Authorization:Basic $encoded" "https://localhost:9090/nwrestapi/v2/global/protectiongroups/" -k -1 2>/dev/null});
encode is used as below
my %BASE_HASH = ();
read_config(\%BASE_HASH);
my $encoded = MIME::Base64::encode($BASE_HASH{NW_USER} . ":" . $BASE_HASH{NW_PW});
It looks like the response you're getting from your HTTP request used to be a JSON string and is now an HTML document.
from_json
is trying to decode it as a JSON string but failing because what it finds is neither an array, object, number, string, or atom: it's HTML.So the problem is more likely with your external service (the one you're talking to) than with the Perl script you're using. Which also might explain why it started failing all of a sudden.