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

APIError: There were no sales for the date specified. Any way to get Units sold for a free app? #15

Closed
rolflocher opened this issue May 16, 2020 · 4 comments

Comments

@rolflocher
Copy link

Our app is free so there is no sales - $ sales data, but there is sales - # units data which I am interested in. I am having trouble getting the download_sales_and_trends_reports to return anything because of this. Also, perhaps the script shouldn't crash when there is a day without sales?

I ended up ditching the manual jwt encoding to try your wrapper because I couldn't set the authorization header with String("Bearer ") + Bytes(encoded_jwt). Perhaps you could help me? Thanks

@ppawlak
Copy link
Contributor

ppawlak commented May 18, 2020

Thank you for reporting this issue.
I'll try to have a look at it as soon as possible.

@ppawlak
Copy link
Contributor

ppawlak commented May 20, 2020

@rolflocher I tried on my account and I am able to download reports even on days with no sales.

Here is the example call I do
api.download_sales_and_trends_reports(filters={'vendorNumber': 'XXXXXX', 'frequency': 'DAILY', 'reportDate': '2020-03-18'}, save_to='report.csv')

Can you paste the call you are doing and the python traceback you get?

@rolflocher
Copy link
Author

api.download_sales_and_trends_reports(filters={'vendorNumber': '99999999', 'frequency': 'DAILY', 'reportDate': '2020-04-10'}, save_to='report.csv')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/appstoreconnect/api.py", line 407, in download_sales_and_trends_reports
    response = self._api_call(url)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/appstoreconnect/api.py", line 134, in _api_call
    raise APIError(payload.get('errors', [])[0].get('detail', 'Unknown error'))
appstoreconnect.api.APIError: There were no sales for the date specified.

But that is for last month, when I change the date to this month it works fine.

@ppawlak
Copy link
Contributor

ppawlak commented May 20, 2020

But that is for last month, when I change the date to this month it works fine.

Well, then I think it means that you had no downloads on 2020-04-10.

Also, perhaps the script shouldn't crash when there is a day without sales?

You should call the API in a try / except block like this:

from appstoreconnect.api import APIError

try:
    api.download_sales_and_trends_reports(filters={'vendorNumber': '99999999', 'frequency': 'DAILY', 'reportDate': '2020-04-10'}, save_to='report.csv')
except APIError as e:
    print("Could not download report because: ", e)

I am also closing this issue as raising an exception on errors is the desired behavior.
Let me know if you need more help though.

@ppawlak ppawlak closed this as completed May 20, 2020
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