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

400: Invalid GetItemCommunicationsRequest.ClassUnitType: value is not a valid enum #190

Closed
shptecheu opened this issue Oct 18, 2023 · 11 comments · Fixed by #193
Closed

400: Invalid GetItemCommunicationsRequest.ClassUnitType: value is not a valid enum #190

shptecheu opened this issue Oct 18, 2023 · 11 comments · Fixed by #193
Assignees

Comments

@shptecheu
Copy link

Hey,

I intend to use this library as a backend and write a fancy frontend on it. I made an api layer using flask to call the library but I encountered some issues.

Calling the getitem API results in the following repsonse:
ikea_api.exceptions.NotSuccessError: (400, '{"error":{"code":400,"message":"invalid GetItemCommunicationsRequest.ClassUnitType: value is not a valid enum"}}')

Code snippet:
constants = ikea_api.Constants(country="it", language="it", base_url="https://www.ikea.com") itemCode = ["00366301","29902933","60366303"] items = await ikea_api.get_items(constants,itemCode)

My question is do I ignore the 400?
I am hoping someone managed to get around this.

@shptecheu
Copy link
Author

Pinging @vrslev for visibility.

@vrslev
Copy link
Owner

vrslev commented Oct 22, 2023

Hey there! Can you send full traceback?

@shptecheu
Copy link
Author

Error on request:
Traceback (most recent call last):
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\werkzeug\serving.py", line 364, in run_wsgi
execute(self.server.app)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\werkzeug\serving.py", line 325, in execute
application_iter = app(environ, start_response)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\flask\app.py", line 2213, in call
return self.wsgi_app(environ, start_response)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\flask\app.py", line 2193, in wsgi_app
response = self.handle_exception(e)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\flask\app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\flask\app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\flask\app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\flask\app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "C:\Python310\lib\concurrent\futures_base.py", line 439, in result
return self.__get_result()
File "C:\Python310\lib\concurrent\futures_base.py", line 391, in __get_result
raise self._exception
File "C:\Users\micha\Documents\projects\IKEA\ikea_api\app.py", line 42, in item
item = await ikea_api.get_items(constants,codes)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\ikea_api\wrappers\wrappers.py", line 217, in get_items
ingka_pip = await _get_ingka_pip_items(constants=constants, item_codes=pending)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\ikea_api\wrappers\wrappers.py", line 169, in _get_ingka_pip_items
ingka_resp, pip_resp = await asyncio.gather(
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\ikea_api\wrappers\wrappers.py", line 142, in _get_ingka_items
responses = await asyncio.gather(*tasks)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\ikea_api\executors\httpx.py", line 74, in run_async
return await HttpxExecutor.run(endpoint)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\ikea_api\abc.py", line 137, in run
handler(response_info)
File "c:\Users\micha\Documents\projects\IKEA\ikea_api.venv\lib\site-packages\ikea_api\error_handlers.py", line 24, in handle_not_success
raise NotSuccessError(response)
ikea_api.exceptions.NotSuccessError: (400, '{"error":{"code":400,"message":"invalid GetItemCommunicationsRequest.ClassUnitType: value is not a valid enum"}}')

@vrslev vrslev self-assigned this Oct 24, 2023
vrslev added a commit that referenced this issue Oct 24, 2023
* Fix typing issue

* Fix access to Ingka Item endpoint in non-russia locations

Fixes #190
@vrslev
Copy link
Owner

vrslev commented Oct 24, 2023

Fixed the issue in v2.1.1 🫶

@shptecheu
Copy link
Author

Thanks for the quick response on the matter.

Incidentally I just tested the changes:

For an item that does not exist, it returns an empty response with code 200. (I am assuming this is expected)
For an existing item, it is returning the same error. Seemingly, it fails to parse and errors out.

Sorry for the bad news :/.

@vrslev
Copy link
Owner

vrslev commented Oct 25, 2023

Oh, I see. Can you send the item code?

@vrslev vrslev reopened this Oct 25, 2023
@shptecheu
Copy link
Author

sure. I tried these ones: "00366301","29902933","60366303"

@vrslev
Copy link
Owner

vrslev commented Oct 25, 2023

Same ones you mentioned earlier—got it. I’ll see what I can do when I’ll get back from work.

@shptecheu
Copy link
Author

shptecheu commented Oct 25, 2023 via email

@vrslev
Copy link
Owner

vrslev commented Oct 25, 2023

Weird.

This code:

import asyncio
from pprint import pprint

import ikea_api

constants = ikea_api.Constants(country="it", language="it")
item_codes = ["00366301", "29902933", "60366303"]
items = asyncio.run(ikea_api.get_items(constants=constants, item_codes=item_codes))
pprint(items)

outputs:

[ParsedItem(is_combination=False, item_code='00366301', name='BEKANT, Piano tavolo, impiallacciato rovere mord bianco, 160x80 cm', image_url='https://www.ikea.com/it/it/images/products/bekant-piano-tavolo-impiallacciato-rovere-mord-bianco__0734707_pe739602_s5.jpg', weight=14.95, child_items=[], price=110, url=HttpUrl('https://www.ikea.com/it/it/p/bekant-piano-tavolo-impiallacciato-rovere-mord-bianco-00366301/', ), category_name='BEKANT piani tavolo per ufficio', category_url=HttpUrl('https://www.ikea.com/it/it/cat/bekant-piani-tavolo-per-ufficio-18966/', )),
 ParsedItem(is_combination=True, item_code='29902933', name='BRIMNES, Struttura letto con cassetti, bianco/Luröy, 140x200 cm', image_url='https://www.ikea.com/it/it/images/products/brimnes-struttura-letto-con-cassetti-bianco-luroey__1151024_pe884762_s5.jpg', weight=0.0, child_items=[ChildItem(name=None, item_code='50228717', weight=0.0, qty=1), ChildItem(name=None, item_code='90124534', weight=0.0, qty=1), ChildItem(name=None, item_code='50160208', weight=0.0, qty=2)], price=249, url=HttpUrl('https://www.ikea.com/it/it/p/brimnes-struttura-letto-con-cassetti-bianco-luroey-s29902933/', ), category_name='Letti matrimoniali, king size e una piazza e mezza', category_url=HttpUrl('https://www.ikea.com/it/it/cat/letti-matrimoniali-16284/', )),
 ParsedItem(is_combination=False, item_code='60366303', name='BEKANT, Piano tavolo, impiallacc frassino/mordente nero, 160x80 cm', image_url='https://www.ikea.com/it/it/images/products/bekant-piano-tavolo-impiallacc-frassino-mordente-nero__0734703_pe739598_s5.jpg', weight=14.95, child_items=[], price=110, url=HttpUrl('https://www.ikea.com/it/it/p/bekant-piano-tavolo-impiallacc-frassino-mordente-nero-60366303/', ), category_name='BEKANT piani tavolo per ufficio', category_url=HttpUrl('https://www.ikea.com/it/it/cat/bekant-piani-tavolo-per-ufficio-18966/', ))]

To me it seems like an expected response: data correctly received, parsed, validated and retrieved.

@shptecheu
Copy link
Author

shptecheu commented Oct 27, 2023 via email

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

Successfully merging a pull request may close this issue.

2 participants