json – Response object is not subscriptable Python http post request
json – Response object is not subscriptable Python http post request
The response
object contains much more information than just the payload. To get the JSON data returned by the POST request, youll have to access response.json()
as described in the example:
requestpost = requests.post(url, json=data, auth=(username, password))
response_data = requestpost.json()
print(response_data[requestId])
You should convert your response to a dict:
requestpost = requests.post(url, json=data, auth=(username, password))
res = requestpost.json()
print(res[requestId])