When I am using following command, I get proper json response from the url:
curl --user user:password -H Accept:application/json -H Content-Type:application/json -X GET <url>
"body": { "items": [ {........}]}
However, when I am trying to do same using python request module
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
user='admin'
password='yanQE3B'
url=<requestUrl>
response = requests.get(url, auth=(user, password) , verify=False)
print ( response.content ) ## prints html content
print ( response.text ) ## prints html content
data = response.json() ## error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
when i do request.json() , I get an error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
when i print request.content - it returns html list with html content. Output of reponse.text and response.content is same. Truncated html as large number of li tags get returned :
<!DOCTYPE html>
<html>
<head>
<title>Data</title>
</head>
<div>
<ul>
<li>
body
<ul>
<li>items <ol>
<li>
<ul>
<li>name ........ </li><li>messages <ol>
</ol></li></ul></div></body></html>