I am trying to get a response from a API call in python 3.5 and need to filter out the output.
The http response was converted to the dictionary, however, i am not able to apply dictionary functions on it for some reason.
I would like to print key,value from the dictionary using standard builtin functions like result.items(), result.keys() etc
Code:
import os
import json
from xml.etree.ElementTree import ElementTree
import requests
import urllib
import requests
url = 'http://demo.assetexplorer.com/api/cmdb/ci/count/all?OPERATION_NAME=read&TECHNICIAN_KEY=5E28C6CA-CCE2-4C2F-A91D-B37CCA17C629'
response = urllib.request.urlopen(url)
result = json.loads(response.readline().decode('utf-8'))
print(type(result))
print(result)
Output:
<class 'dict'>
{'API': {'response': {'operation': {'name': 'read', 'Details': {'field-values': {'record': {'value': 203}, 'totalRecords': 1}, 'field-names': {'name': {'content': 'Count', 'type': 'Integer'}}}, 'result': {'status': 'Success', 'created-date': 'Jul 28, 2018 03:36 PM', 'statuscode': 200, 'message': 'Successfully fetched.'}}}, 'version': 1}}
The type() does show the variable is a dict, what am i missing here?
Image of what i see for the "result" variable