Getting JSON parameter from requests, I get: 'method' object is not subscriptable

Kre*_*ten 4 python json python-requests

I'm trying to get a parameter from a JSON string loaded with requests.

I think I tried any combination I can think of.

Any hints are very appreciated.

My code is this:

r = requests.get(url, headers=headers)
json_string = r.json
status = json.dumps(json_string['httpStatusCode'])
Run Code Online (Sandbox Code Playgroud)

and I'm getting

'method' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)

小智 5

The error you are getting because you are assigning a "method" object to json_string.
Since in python "method" objects are not subscriptable.

To get JSON response you have to do this

json_string = r.json()
Run Code Online (Sandbox Code Playgroud)