if response.status_code == 201:
report_data = response.json()
report_id = report_data[‘report’][‘id’]
print(f"Successfully created report with ID: {report_id}")
else:
print(“Failed to create the report. Error:”, response.text)
When checking the response status, I get “Failed to create the report. Error:” printed. So also the response.text seems to be empty. How can I successfully create a sales report?
How are you pulling the sales data that your app will use to generate the sales report? The report resource will let you create a report, but you can’t access any other reports or data that isn’t created by your app via this resource: “Reports are scoped to the app that created them. When an app creates a report, other apps can’t view, modify, or delete that report. Also, apps can’t access reports that were created from the Shopify admin.”
I believe the issue here could be related to how you’re getting the sales data - you likely will want to access the orders.json endpoint to gather the required data by fetching Orders, Refunds, Transactions, etc via the API and then calculate the sales figures in your Python application.
Thanks a lot for your reply. I did this, I used initially the orders.json endpoint and calculated sales from this. However this isn’t ideal as orders get refunded for example. Ideally, I want the sales numbers being reported in Shopify.
I understand that you can only get reports from your app that created them. So that’s what I am trying to do: create a sales report with my app and then subsequently get the reports in the future using my app.