Report Download API not working for static reports

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

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 - Dimagi Confluence

Hi Cory, Yes I did use that doc and the api response is only a List of dynamic reports.
I also use this doc and When I try replacing the REPORTID with a static report Id , it is not working.


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

Let's see what Dimagi team says.


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

Great , Thank you cory

@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

Hi @andyasne - it appears from the screenshot that you're accessing a different API - the 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.

hi @czue
here is the log after calling the api

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/", 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/", 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/", 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/", 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/", 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/", 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/", 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/", 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/", 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/", line 102, in <dictcomp>
    for filter in filters
  File "/home/cchq/www/echis/releases/2021-10-05_16.19/corehq/apps/reports_core/", 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/", 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/", 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/

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

1 Like

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.


Will do that , Thank You Cory