easypost-python icon indicating copy to clipboard operation
easypost-python copied to clipboard

Unhelpful Error Message During Tracker.create

Open att14 opened this issue 5 years ago • 1 comments

>>> easypost.Tracker.create('2756302021', carrier='DHLExpress')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tribone/Library/Python/3.7/lib/python/site-packages/easypost/__init__.py", line 590, in create
    response, api_key = requestor.request('post', url, wrapped_params)
  File "/Users/tribone/Library/Python/3.7/lib/python/site-packages/easypost/__init__.py", line 260, in request
    response = self.interpret_response(http_body, http_status)
  File "/Users/tribone/Library/Python/3.7/lib/python/site-packages/easypost/__init__.py", line 321, in interpret_response
    self.handle_api_error(http_status, http_body, response)
  File "/Users/tribone/Library/Python/3.7/lib/python/site-packages/easypost/__init__.py", line 383, in handle_api_error
    raise Error(error.get('message', ''), http_status, http_body)
easypost.Error: This api key is no longer active. Please use a different api key or reactivate this key.

The call is supposed to be easypost.Tracker.create(tacking_code='2756302021', carrier='DHLExpress'), but the error says that the api key configured is not active.

att14 avatar Mar 29 '20 00:03 att14

For posterity:

The API key is the only positional argument to all create calls. This could be changed by making api_key a non-positional argument (e.g., pulling it out of kwargs), but that would be a breaking change for anyone currently relying on it as a positional argument.

Roguelazer avatar Apr 01 '20 18:04 Roguelazer

The ability to pass an api_key to functions has been removed in the upcoming v8 release of this library. Instead, functions are called against a client object that wraps an API key once instantiated. This should correct this issue.

Justintime50 avatar May 17 '23 18:05 Justintime50