Change in API calling syntax

We have been using the following API for last 2 years for getting the list of org units from DHIS2 to keep an external system’s facility list in sync -

https://*****/api/organisationUnits.json?fields=[id,name,openingDate,closedDate]

The version was 2.36.x. When the version was updated to 2.4, the API stopped working, and finally we found that this does work (without the third brackets) -

https://*****/api/organisationUnits.json?fields=id,name,openingDate,closedDate

Just checking whether this change was intentional or not. I did not go through version Whats New documentation, maybe this was mentioned.

We would expect that you should not do breaking changes in existing APIs. Anyone from dev team can comment?

Hi @Mahmud

I’ve used the the fields parameters without brackets and only brackets when there’s a nested object. https://play.dhis2.org/2.38.6/api/users?fields=id,username,userRoles[*]&filter=username:eq:admin

I could do this: fields=[id,username,userRoles] but this will stop me from getting all the fields in userRoles[*]

Thanks!

@Gassim I understand the reason behind removing the brackets now, for nested objects.

But, this also means, we should watch out of breaking existing software every time a DHIS2 version is rolled out. Sometimes, teams managing DHIS2 do not inform all parties (specially external ones) when they do the version updates…this will result in silent killing of existing functionality.

Anyway, good to know this was intentional and not a bug or missed out.

Hi @Mahmud

Thanks for your note… I can’t recall a time when I saw the brackets used the way you mentioned so it must have been a very long time ago; nonetheless, I know for a fact that the team try their best to ensure that all changes are logged and are published with every release: GitHub - dhis2/dhis2-releases: Release information for DHIS 2