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: 'details' when using US zip codes #33

Closed
sqr opened this issue Sep 5, 2021 · 1 comment · Fixed by #34
Closed

KeyError: 'details' when using US zip codes #33

sqr opened this issue Sep 5, 2021 · 1 comment · Fixed by #34

Comments

@sqr
Copy link
Contributor

sqr commented Sep 5, 2021

Hello, I am investigating the following error:

Traceback (most recent call last):
  File "ikea.py", line 17, in <module>
    api.OrderCapture(zip_code="02215")
  File "/home/square/ikea-api/ikea_api/core.py", line 64, in OrderCapture
    return OrderCapture(self._token, zip_code)()
  File "/home/square/ikea-api/ikea_api/endpoints/order_capture/__init__.py", line 29, in __call__
    return self.get_delivery_services()
  File "/home/square/ikea-api/ikea_api/endpoints/order_capture/__init__.py", line 93, in get_delivery_services
    delivery_area = self._get_delivery_area(checkout)
  File "/home/square/ikea-api/ikea_api/endpoints/order_capture/__init__.py", line 80, in _get_delivery_area
    response = self._call_api(
  File "/home/square/ikea-api/ikea_api/api.py", line 70, in _call_api
    self._error_handler(response.status_code, response_dict)
  File "/home/square/ikea-api/ikea_api/endpoints/order_capture/__init__.py", line 33, in _error_handler
    raise OrderCaptureError(response)
  File "/home/square/ikea-api/ikea_api/errors.py", line 44, in __init__
    if response["message"] == response["details"]
KeyError: 'details'

It seems to happen with all the United States zip codes I have tried.

My script is as follows:

from ikea_api import IkeaApi

api = IkeaApi(
    token=...,  # If you already have a token and stored it somewhere
    country_code="us",
    language_code="en",
)

api.login_as_guest()

cart = api.Cart
cart.add_items({"90446761": 1})
# print(cart.show())

api.OrderCapture(zip_code="02215")

Showing the cart works.

I am going to query the api manually and see how the response looks, in case I can spot the problem.

@sqr
Copy link
Contributor Author

sqr commented Sep 5, 2021

Fixed this, will send a PR in a little bit

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.

1 participant