Community Health Toolkit

CHT's integration with DHIS2 - file containing the dataValueSet doesn't download

Hello
I am trying to integrate the CHT with DHIS2 following this guide: DHIS2 Aggregate | Community Health Toolkit
My configuration looks good and I have done the deployment. But the problem is that the file containing the [dataValueSet] does not download when I click on download.


Here is the log i have when i opened the dev console:

1. Request URL:

https://192-168-1-7.my.local-ip.co:8443/api/v2/export/dhis?filters%5BdataSet%5D=hyP81pEpI1Y&filters%5Bdate%5D%5Bfrom%5D=1637184895072

  2. Request Method:

GET

  3. Status Code:

400 Bad Request

  4. Remote Address:

192.168.1.7:8443

  5. Referrer Policy:

strict-origin-when-cross-origin

1. Response HeadersView source

  1. Connection:

keep-alive

  2. Content-Disposition:

attachment; filename=dhis-202111172238.json

  3. Content-Encoding:

gzip

  4. Content-Security-Policy:

default-src 'none'; font-src 'self'; manifest-src 'self'; connect-src 'self' https://staging.dev.medicmobile.org/_couch/builds/ maps.googleapis.com; child-src 'self'; form-action 'self'; img-src 'self' data: blob: *.openstreetmap.org; media-src 'self' blob:; script-src 'self' 'sha256-B5cfIVb4/wnv2ixHP03bHeMXZDszDL610YG5wdDq/Tc=' 'unsafe-eval' 'unsafe-hashes' 'sha256-2rvfFrggTCtyF5WOiTri1gDS8Boibj4Njn0e+VCBmDI='; style-src 'self' 'unsafe-inline'

  5. Content-Type:

text/plain

  6. Date:

Wed, 17 Nov 2021 22:38:07 GMT

  7. Server:

nginx/1.19.10

  8. Strict-Transport-Security:

max-age=15552000; includeSubDomains

  9. Transfer-Encoding:

chunked

  10. Vary:

Accept-Encoding

  11. X-Content-Type-Options:

nosniff

  12. X-DNS-Prefetch-Control:

off

  13. X-Download-Options:

noopen

  14. X-Frame-Options:

SAMEORIGIN

  15. X-XSS-Protection:

1; mode=block

2. Request HeadersView source

  1. Accept:

text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

  2. Accept-Encoding:

gzip, deflate, br

  3. Accept-Language:

en-SN,en;q=0.9,fr-SN;q=0.8,fr;q=0.7,en-GB;q=0.6,en-US;q=0.5

  4. Cache-Control:

max-age=0

  5. Connection:

keep-alive

  6. Cookie:

AuthSession=dGVzdC1tYW5hZ2VyOjYxOTU3NTczOmeEQuCGWz0g4a1-1w5X3XRQDonw; userCtx=%7B%22name%22%3A%22test-manager%22%2C%22roles%22%3A%5B%22national_admin%22%2C%22mm-online%22%5D%2C%22home%22%3A%22%2Fadmin%2F%22%7D; locale=en

  7. Host:

192-168-1-7.my.local-ip.co:8443

  8. sec-ch-ua:

"Google Chrome";v="95", "Chromium";v="95", ";Not A Brand";v="99"

  9. sec-ch-ua-mobile:

?0

  10. sec-ch-ua-platform:

"Windows"

  11. Sec-Fetch-Dest:

document

  12. Sec-Fetch-Mode:

navigate

  13. Sec-Fetch-Site:

cross-site

  14. Sec-Fetch-User:

?1

  15. Upgrade-Insecure-Requests:

1

  16. User-Agent:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

3. Query String Parametersview sourceview URL-encoded

  1. filters[dataSet]:

hyP81pEpI1Y

  2. filters[date][from]:

1637184895072

I would appreciate your help

1 Like

Hi @Justinho

I’m sorry the UI is not providing more information about the error that you are encountering. We already have an open issue to improve this: Improve admin export error handling · Issue #6475 · medic/cht-core · GitHub however no delivery date.
In the meantime, could you please check the medic-api logs? You should see an error logged every time you attempt and fail the export.
For example:

2021-11-18 12:37:41 INFO: Export requested for "dhis" 
2021-11-18 12:37:41 INFO:   filters: {
  "dataSet": "VMuFODsyWaO",
  "date": {
    "from": 1634557060169
  }
} 
2021-11-18 12:37:41 INFO:   options: {
  "humanReadable": false
} 
2021-11-18 12:37:41 ERROR: dataSet "VMuFODsyWaO" has no dataElements 

@Justinho Does it work if you manually make the request https://192-168-1-7.my.local-ip.co:8443/api/v2/export/dhis?dataSet=hyP81pEpI1Y&from=1637184895072

@diana The UI is making a request to https://192-168-1-7.my.local-ip.co:8443/api/v2/export/dhis?filters[dataSet]=hyP81pEpI1Y&filters[date][from]=1637184895072 … Is that the expected path/querystring?
(400 Bad Request)

The former was the expected path in 3.10, but perhaps this pathing has changed in recent versions (this is 3.13).

Looking at the API documentation that looks like a bug in the admin app. I’ll investigate and raise an issue later today.

After investigating locally that funky looking URL is actually correct so it should work.

@diana is correct - there should be an error message in the log. The error should also be visible in the response body. To access this press F12 to load dev tools, go to the Network tab, select the request, select the Response tab, and you should see something like: dataSet "xyz" is not defined.

1 Like

Thank you for your feedback
@diana here is the error I have in the medic-api log:
[2021-11-19 11:59:33] 2021-11-19 11:59:33 ESC[32mINFOESC[39m: Export requested for “dhis”

[2021-11-19 11:59:33] REQ 26125bf3-e223-4727-8ba5-3a7341189dd6 172.18.0.1 - GET /api/v2/export/dhis?filters%5BdataSet%5D=hyP81pEpI1Y&filters%5Bdate%5D%5Bfrom%5D=1637323168396 HTTP/1.0
[2021-11-19 11:59:33] 2021-11-19 11:59:33 ESC[32mINFOESC[39m: Export requested for "dhis"
[2021-11-19 11:59:33] 2021-11-19 11:59:33 ESC[32mINFOESC[39m:   filters: {
[2021-11-19 11:59:33]   "dataSet": "hyP81pEpI1Y",
[2021-11-19 11:59:33]   "date": {
[2021-11-19 11:59:33]     "from": 1637323168396
[2021-11-19 11:59:33]   }
[2021-11-19 11:59:33] }
[2021-11-19 11:59:33] 2021-11-19 11:59:33 ESC[32mINFOESC[39m:   options: {
[2021-11-19 11:59:33]   "humanReadable": false
[2021-11-19 11:59:33] }
[2021-11-19 11:59:33] 2021-11-19 11:59:33 ESC[31mERRORESC[39m: dataSet "hyP81pEpI1Y" has no dataElements

yet the dataset has a dataElements in my config:

dhis: {
      dataSet: 'hyP81pEpI1Y',
      dataElement: 'FMIuOQ9vNSM'
    }

@kenn it doesn’t work if I manually make the request https://192-168-1-7.my.local-ip.co:8443/api/v2/export/dhis?dataSet=hyP81pEpI1Y&from=1637184895072

@Justinho

This means that you have no targets configured to use this data element.
Can you please check your target definitions to see if this data set exists? Here is some relevant documentation: DHIS2 Aggregate | Community Health Toolkit and code that gets the targets cht-core/dhis.js at 400fd7658948160b88d2933c1032b3becbe3bae5 · medic/cht-core · GitHub