plaid/plaid-python

plaid.errors.APIError: an unexpected error occurred

Closed this issue · 1 comments

I'm getting the error plaid.errors.APIError: an unexpected error occurred when I use plaid-python to call the transactions endpoint. The thing is, I made no change to my code since my last time running it (when it worked fine), and I really can't figure out what's going on.

Here's where I call client.Transactions.get:

def getTransactions(items, start_date, end_date):
    transactions = []
    for item in items:
        # for each item, get item transactions, and add to list
        access_token = item.access_token
        new_trans = client.Transactions.get(access_token,
                                        dateFormat(start_date),
                                        dateFormat(end_date))['transactions']
        transactions.extend(new_trans)
    return transactions

where client is assigned earlier as
client = Client(PLAID_CLIENT_ID, PLAID_SECRET, PLAID_PUBLIC_KEY, PLAID_ENV)
(I've checked and the constants are all correct)

And here's my stack trace:

Traceback (most recent call last):
...
  File "/Users/daniellee/Coding/bread2/bread/api/plaid_helpers.py", line 68, in getSpending
    transactions = getTransactions(items, start_date, end_date)
  File "/Users/daniellee/Coding/bread2/bread/api/plaid_helpers.py", line 63, in getTransactions
    dateFormat(end_date))['transactions']
  File "/Users/daniellee/Coding/bread2/venv/lib/python3.7/site-packages/plaid/api/transactions.py", line 49, in get
    'options': options,
  File "/Users/daniellee/Coding/bread2/venv/lib/python3.7/site-packages/plaid/client.py", line 91, in post
    return self._post(path, post_data, is_json)
  File "/Users/daniellee/Coding/bread2/venv/lib/python3.7/site-packages/plaid/client.py", line 114, in _post
    headers=headers,
  File "/Users/daniellee/Coding/bread2/venv/lib/python3.7/site-packages/plaid/requester.py", line 68, in http_request
    raise PlaidError.from_response(response_body)
plaid.errors.APIError: an unexpected error occurred

I've tried debugging it, and found that all the plaid codes (client id, secret, public key, item access token) are correct in client. I'm using sandbox mode.

It started working again the next day, must've been something on Plaid's end.