IoTHubRegistryManager.query_iot_hub throws msrest.exceptions.DeserializationError
See original GitHub issueUsing the azure-iot-hub 2.0.0 on MacOS 10.14.6 with Python 3.6.4 I ran into the above issue details below.
Steps to reproduce:
from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.protocol.models import QuerySpecification
iotrm = IoTHubRegistryManager(MY_CONNECTION_STRING)
q = QuerySpecification(query="SELECT * FROM devices")
iotrm.query_iot_hub(q)
Result:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/azure/iot/hub/iothub_registry_manager.py", line 488, in query_iot_hub
return self.protocol.service.query_iot_hub(query_specification)
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/azure/iot/hub/protocol/operations/service_operations.py", line 614, in query_iot_hub
deserialized = self._deserialize("QueryResult", response)
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1233, in __call__
return self._deserialize(target_obj, data)
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1303, in _deserialize
raise_with_traceback(DeserializationError, msg, err)
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
raise error.with_traceback(exc_traceback)
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1293, in _deserialize
found_value = key_extractor(attr, attr_desc, data)
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1064, in rest_key_extractor
return working_data.get(key)
msrest.exceptions.DeserializationError: Unable to deserialize to object: type, AttributeError: 'list' object has no attribute 'get'
Expected Result: A QueryResult containing the devices in the IoTHub.
If I run the following:
from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.protocol.models import QuerySpecification
iotrm = IoTHubRegistryManager(MY_CONNECTION_STRING)
q = QuerySpecification(query="SELECT * FROM devices")
service = iotrm.protocol.service
url = service.query_iot_hub.metadata["url"]
query_parameters = {}
query_parameters["api-version"] = service._serialize.query("self.api_version", service.api_version, "str")
header_parameters = {}
header_parameters["Accept"] = "application/json"
header_parameters["Content-Type"] = "application/json; charset=utf-8"
body_content = service._serialize.body(q, "QuerySpecification")
request = service._client.post(url, query_parameters, header_parameters, body_content)
response = service._client.send(request, stream=False, **{})
response.status_code
# 200
response.content
# b'[LIST OF DEVICES THAT I EXPECT]'
service._deserialize("QueryResult", response)
Traceback (most recent call last):
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1293, in _deserialize
found_value = key_extractor(attr, attr_desc, data)
File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1064, in rest_key_extractor
return working_data.get(key)
AttributeError: 'list' object has no attribute 'get'
So something is wrong with the deserializer that the ServiceOperations
class uses when it is deserializing a “QueryResult”
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
azure.iot.hub.IoTHubRegistryManager class | Microsoft Learn
A class to provide convenience APIs for IoTHub Registry Manager operations, based on top of the auto generated IotHub REST APIs.
Read more >IoTHubRegistryManager.query_iot_hub throws msrest ...
IoTHubRegistryManager.query_iot_hub throws msrest.exceptions.DeserializationError #859. OS and version used: Windows 10 Python version: 3.9.1 pip version: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We have replicated and identified the problem, and are working to fix it as soon as possible
@capfish, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey