Getting "KeyError: 'd'" when reading XML OData
See original GitHub issueI’m trying to read from this site: http://knesset.gov.il/Odata/ParliamentInfo.svc/
The site is in XML and every table is saved in XML too. For example: http://knesset.gov.il/Odata/ParliamentInfo.svc/KNS_Agenda
When reading with python-pyodata, there is a key error when trying to get entities.
Code:
import requests
import pyodata
SERVICE_URL = 'http://knesset.gov.il/Odata/ParliamentInfo.svc/'
# Create instance of OData client
client = pyodata.Client(SERVICE_URL, requests.Session())
# This is the problematic line
a = client.entity_sets.KNS_Agenda.get_entities().execute()
The exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/.local/lib/python3.6/site-packages/pyodata/v2/service.py", line 305, in execute
return self._handler(response)
File "/home/ubuntu/.local/lib/python3.6/site-packages/pyodata/v2/service.py", line 1102, in get_entities_handler
entities = content['d']['results']
KeyError: 'd'
Is there a way to fix this?
Thanks in advance,
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
KeyError while parsing data from .xml file - python
I found that this KeyError is occurred because some of the files do not contain attribute 'occupied'. To avoid this problem and continue...
Read more >What is KeyError in Python? Dictionary and Handling Them
Here I am trying to access a key called “D” which is not present in the dictionary. Hence, the error is thrown as...
Read more >4.1. Data Consumers — Pyslet 0.6.20160201 documentation - Read ...
Let's start with a simple illustration of how to consume data using the DAL API by walking through the use of the OData...
Read more >How to Fix KeyError Exceptions in Python - Rollbar
The Python KeyError is an exception that occurs when an attempt is made to access an item in a dictionary that does not...
Read more >Invantive(R) SQL 22.0.101 | Release Notes
Fix XML reading not finding any fields - Improve discovery of database definition changes. ... Do not pass PSQL-only data type variables into...
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 Free
Top 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
@aviasd Thank you for taking the time to report this issue. Unfortunately, I do believe the service is OData V3 service which is not supported yet.
I have created an experimental fix which is available on the branch: https://github.com/SAP/python-pyodata/tree/experimental_v3
I was able to run your example without issues with pyodata from that branch. However, I didn’t try to fetch any additional entity sets, so there might be more incompatibilities.
If you have time and you want to help us make pyodata better, please, try to use pyodata from the experimental_v3 branch and report results here.
Hi, Ran in the same problem as aviasd, experimental branch works for me. Thank you guys for the work on this.