How to get json from <class 'requests.models.Response'>

Viewed 841
url = cmsServiceBaseUrl
resp = requests.get(url,json=cmsServiceRequestBaseFormat)
return resp.get("data")

The resp type is <class 'requests.models.Response'> but I want json

2 Answers

You need to call resp.json().

The response will be a JSON parsed into a dictionary or a list of dictionaries.

Here is an example from the docs:

>>> import requests

>>> r = requests.get('https://api.github.com/events')
>>> r.json()
[{'repository': {'open_issues': 0, 'url': 'https://github.com/...
Related