hello
I tried to request JSON from an API using the following script:
request_neu = New HTTP Request(
URL( "https://redacted.com/api/path?fileType=Json" ),
Method( "GET" ),
//headers( {"Accept: text/plain", "Accept: text/html", "Accept: */*"} ),
//headers( {"Accept: */*"} ),
//I tried everything here
Headers( {"Accept: application/json"} ),
Username( "api.user" ),
Password( "redacted" ),
Timeout( 900000 )
);
response = request_neu << send;
show(request_neu << get mime type);
show(request_neu << get status);
show(request_neu << get status message);
show(substr(response,1,999));
JSON to data table(response);
I added the debugging statements after the JSON to data table function resulted in an error and the output is
request_neu << get mime type = "text/html; charset=utf-8";
request_neu << get status = 200;
request_neu << get status message = "HTTP/1.1 200 OK";
Substr(response, 1, 999) = "
<!DOCTYPE html>
<html class=\!"no-js smooth-scrolling-html\!" lang=\!"en-GB\!" dir=\!"ltr\!">
<head>
etc
so essentially instead of JSON I receive html.
The interesting thing is that it works with Postman, Python, even Excel.
The really interesting thing is that some months ago when I created this script it also was working.
Do you have some idea what is going on here?
thx