# Report Download API not working for static reports

**URL:** <https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469>\
**Category:** Developers\
**Created:** [September 28, 2021, 11:28am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469 "2021-09-28T11:28:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [September 28, 2021, 11:28am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/1 "2021-09-28T11:28:27Z")

</div>

Hi,  
All static reports for our project did not show up on the list of reports API and I was not able to access any of them using API? is this intentional?  
is there any way around that other than creating the same reports locally for the API

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [September 28, 2021, 2:50pm UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/2 "2021-09-28T14:50:14Z")

</div>

Hi Andinet,

I doubt this is intentional, but more likely it just hasn't come up. Could you link to the API docs for the API you are trying to use? Is it this one? [List Reports - CommCare Public - CommCare Public](https://confluence.dimagi.com/display/commcarepublic/List+Reports)

---

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [September 29, 2021, 8:20am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/3 "2021-09-29T08:20:32Z")

</div>

Hi Cory, Yes I did use that doc and the api response is only a List of dynamic reports.  
I also use [this](https://confluence.dimagi.com/display/commcarepublic/Download+Report+Data) doc and When I try replacing the REPORTID with a static report Id , it is not working.

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [September 29, 2021, 12:17pm UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/4 "2021-09-29T12:17:15Z")

</div>

Hey,

I've proposed a fix for this: [Add static reports and remove temporary reports from UCR report api by czue · Pull Request #30491 · dimagi/commcare-hq · GitHub](https://github.com/dimagi/commcare-hq/pull/30491)

Let's see what Dimagi team says.

Cory

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [October 4, 2021, 7:40am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/5 "2021-10-04T07:40:30Z")

</div>

Hi @andyasne the proposed change was accepted and I believe rolled out to the production environment, so this should be fixed/supported now.

---

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [October 4, 2021, 8:16am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/6 "2021-10-04T08:16:16Z")

</div>

Great , Thank you cory

---

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [October 6, 2021, 7:52am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/7 "2021-10-06T07:52:23Z")

</div>

@czue After redeployment, I tested the API and the same error message is returning.  
the thing is all the old dynamic report api works, but whenever you create a new dynamic report or use any static report it returns this error

 ![image](https://dimagi.b-cdn.net/uploads/default/original/2X/9/9eb9333d8e3a5ee76e5987cfab054672eefc1ef0.png)

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [October 7, 2021, 7:28am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/8 "2021-10-07T07:28:27Z")

</div>

Hi @andyasne - it appears from the screenshot that you're accessing a different API - the [Download Report Data](https://confluence.dimagi.com/display/commcarepublic/Download+Report+Data) one.

The error message you're seeing is a generic error message that will be shown if the report data cannot be generated. It could have to do with a missing/stale data source, a bad configuration file, or a bug in CommCare HQ's code.

To know how to troubleshoot further would require seeing the logs associated with the underlying error, which should be available in your server logs or in Sentry if you are using the standard logging configuration.

If you can share those I may be able to provide more guidance.

---

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [October 8, 2021, 6:54pm UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/9 "2021-10-08T18:54:08Z")

</div>

hi @czue  
here is the log after calling the api

```auto
2021-10-08 06:16:25,736 ERROR Internal Server Error: /a/fmoh-echis/api/v0.5/configurablereportdata/953055aec3d97d82177d80c3ec841e38/
Traceback (most recent call last):
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/python_env-3.6/lib/python3.6/site-packages/tastypie/resources.py", line 227, in wrapper
    response = callback(request, *args, **kwargs)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/python_env-3.6/lib/python3.6/site-packages/tastypie/resources.py", line 476, in dispatch_detail
    return self.dispatch('detail', request, **kwargs)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/api/resources/ __init__.py", line 110, in dispatch
    return super(HqBaseResource, self).dispatch(request_type, request, **kwargs)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/python_env-3.6/lib/python3.6/site-packages/tastypie/resources.py", line 499, in dispatch
    response = method(request, **kwargs)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/python_env-3.6/lib/python3.6/site-packages/tastypie/resources.py", line 1383, in get_detail
    obj = self.cached_obj_get(bundle=basic_bundle, **self.remove_api_resource_names(kwargs))
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/python_env-3.6/lib/python3.6/site-packages/tastypie/resources.py", line 1202, in cached_obj_get
    cached_bundle = self.obj_get(bundle=bundle, **kwargs)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/api/resources/v0_5.py", line 761, in obj_get
    report_config, domain, start, limit, bundle.request.GET)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/api/resources/v0_5.py", line 734, in _get_report_data
    query_dict_to_dict(get_params, domain, string_type_params)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/userreports/reports/view.py", line 102, in get_filter_values
    for filter in filters
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/userreports/reports/view.py", line 102, in <dictcomp>
    for filter in filters
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/reports_core/filters.py", line 60, in get_value
    return self.default_value(**kwargs)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/reports_core/filters.py", line 404, in default_value
    choice_provider_default = self.choice_provider.default_value(request_user)
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/userreports/reports/filters/choice_providers.py", line 323, in default_value
    location = user.get_sql_location(self.domain)
AttributeError: 'NoneType' object has no attribute 'get_sql_location'
2021-10-08 06:16:25,756 ERROR Internal Server Error: /a/fmoh-echis/api/v0.5/configurablereportdata/953055aec3d97d82177d80c3ec841e38/
2

```

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [October 11, 2021, 7:55am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/10 "2021-10-11T07:55:37Z")

</div>

Hi @andyasne - this appears to be of bug in the API code. It looks like the user details are not being properly passed through to all the filters.

I've proposed another fix for this issue, and we can again see if it goes through: [pass user through to filters in report data API by czue · Pull Request #30557 · dimagi/commcare-hq · GitHub](https://github.com/dimagi/commcare-hq/pull/30557)

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [October 11, 2021, 2:40pm UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/11 "2021-10-11T14:40:17Z")

</div>

Hi again,

The change was accepted, so if you're running you're own CommCare server you could try updating and seeing if it fixes the issue for you now.

best,  
Cory

---

<div class="post-metadata">

**Author:** ![andyasne](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/andyasne/32/2626_2.png) [@andyasne](https://forum.dimagi.com/u/andyasne)\
**Post date:** [October 12, 2021, 6:59am UTC](https://forum.dimagi.com/t/report-download-api-not-working-for-static-reports/8469/12 "2021-10-12T06:59:11Z")

</div>

Will do that , Thank You Cory
