Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError when retrieving "bulkOperation " #54

Closed
zhaoyutongxue opened this issue Jun 1, 2024 · 0 comments
Closed

KeyError when retrieving "bulkOperation " #54

zhaoyutongxue opened this issue Jun 1, 2024 · 0 comments
Assignees
Milestone

Comments

@zhaoyutongxue
Copy link

`def getOperation():

bos = c8y.bulk_operations.select(limit=3)

for bo in bos:
    print(bo.status)`

Hi Chris,

Hope you are well!

when I tried to run the above code to get "Bulk Operation" from Cumulocity, I encountered the below KeyError.

Traceback (most recent call last):
File "C:\xxx\opt.py", line 3, in
object4.getOperation()
File "C:\xxx\operation\object4.py", line 9, in getOperation
for bo in bos:
File "C:\xxx\Lib\site-packages\c8y_api\model_base.py", line 556, in _iterate
results = [parse_func(x) for x in self._get_page(base_query, current_page)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\xxx\Lib\site-packages\c8y_api\model_base.py", line 541, in _get_page
return result_json[self.object_name]
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'bulkoperations'

It looks to me the problem is:
The key in the API response is: "bulkOperations" with capital "O".
But "_get_page
return result_json[self.object_name]" is using "bulkoperations" as the key, with the lower case "o"

Hence the KeyError exception happened.

Regards
Henry

chisou pushed a commit that referenced this issue Jun 4, 2024
@chisou chisou self-assigned this Jun 4, 2024
@chisou chisou added this to the 1.11 milestone Jun 4, 2024
chisou pushed a commit that referenced this issue Jul 2, 2024
chisou added a commit that referenced this issue Aug 1, 2024
Co-authored-by: Christoph Souris <christoph.souris@softwareag.com>
@chisou chisou closed this as completed Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants