Troubleshooting DHIS2 jobs

Just doing some prototyping to familiarize myself with OpenFn + DHIS2. I set up a job where I submit a hard coded data value set to the DHIS2 demo server. I’m able to successfully curl the same payload directly to DHIS2, but when I set up the job in OpenFn, it says the job failed (see screenshot). Any advice on what may be the issue or how to troubleshoot?

curl -d @datavalueset.jsonhttps://play.dhis2.org/dev/api/dataValueSets” -H “Content-Type:application/json” -u admin:district | json_pp

{
“dataSet”: “pBOMPrpg1QX”,
“completeData”: “2014-03-03”,
“period”: “201402”,
“orgUnit”: “DiszpKrYNg8”,
“dataValues”: [
{ “dataElement”: “f7n9E0hX8qk”, “value”: “10” },
{ “dataElement”: “Ix2HsbDMLea”, “value”: “20” },
{ “dataElement”: “eY5ehpbEsB7”, “value”: “30” }
]
}

openfn_dhis2_datavalueset_run_1133527.png

datavalueset.json (293 Bytes)

Hey Michael, happy to help! Would you be willing to post your job expression on the forum?

Taylor

Try this out. I ran the following just now and it worked:

dataValueSet(
fields(
field(“dataSet”, “pBOMPrpg1QX”),
field(“orgUnit”, “DiszpKrYNg8”),
field(“period”, “201402”),
field(“completeData”, “2014-03-03”),
field(“dataValues”, function(state) {
return [
dataElement(“f7n9E0hX8qk”, 10),
dataElement(“Ix2HsbDMLea”, 20),
dataElement(“eY5ehpbEsB7”, 30)
]
})
)
)

Hope this helps. Would still love to see your job so I can get a sense of how you were interpreting the README.md and we can make some clarifications.

Best,
Taylor

Thanks Taylor! That worked. The issue I had was with the second parameter I provided to dataElement… I sent the string “10” instead of the number 10. Rookie mistake !

openfnjobdef.png

Very cool. Also, make sure you’re using the latest version of the dhis2 adaptor so you’ve got access to the helpers. Should look like this:

image.png

Hmm… I don’t see those helpers. I have ‘Latest (auto-upgrade)’ selected for the version of the DHIS2 adapter.

Two other things I tried… (1) specifically selecting the latest version (v0.1.0); and (2) creating a new job (instead of editing an existing) but alas, still no helpers.

Screen Shot 2017-09-08 at 2.43.58 PM.png

One more thought… The documentation for dhis2 is pretty new. Can you try a hard-refresh on the page to clear your cache? On Chrome it’s cntrl-shift-r, or command-shift-r.

Taylor

I can see it now, thanks!