Report Download API not working for static reports

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

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

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.

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

Let's see what Dimagi team says.

Cory

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/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

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.

best,
Cory

Will do that , Thank You Cory