Secure policy
Secure policy

Reputation: 21

print response from post request

I am trying to print response from a post request in python. Response shall be print in list. I tried the below code but i only get status code 200. Need help to print response body as per screenshot below .

import requests
r = requests.get('URL')
print r.json

API Response Screenshot

Upvotes: 1

Views: 20549

Answers (1)

Patrick, I hope this code can help you:

import requests
import json
import pprint

r = requests.get('URL')
pprint.pprint(json.loads(r.content))

pprint is only to see the output, I guess the main point for you are the json.loads and r.content.

Best Regards!

Upvotes: 4

Related Questions