I wanted to follow up on our previous conversation about retrieving the createdBy
and lastUpdatedBy
fields using the /api/users
endpoint. I decided to test the API on the DHIS2 Play instance (version 2.40.4.1), and I was able to retrieve these fields correctly.
Here’s the API call I used:
https://play.im.dhis2.org/stable-2-40-4-1/api/39/users?fields=id,createdBy,lastUpdatedBy&paging=false
JSON Response
When testing on the Play instance, I received the following JSON response structure, which includes the createdBy
and lastUpdatedBy
fields:
{
"users": [
{
"id": "FLDWwCTIsv9",
"createdBy": {
"id": "GOLswS44mh8",
"name": "Tom Wakiki",
"displayName": "Tom Wakiki",
"username": "system"
},
"lastUpdatedBy": {
"id": "GOLswS44mh8",
"name": "Tom Wakiki",
"displayName": "Tom Wakiki",
"username": "system"
}
},
// ... other users
]
}
This JSON response correctly includes both createdBy
and lastUpdatedBy
fields, providing the user ID, name, displayName, and username for the respective fields.
XML Response
I also tested the response in XML format to check if it delivers the same data correctly. Here’s the API call for the XML format:
https://play.im.dhis2.org/stable-2-40-4-1/api/39/users.xml?fields=id,createdBy,lastUpdatedBy&paging=false
And here’s an example of the XML response:
<users>
<user id="FLDWwCTIsv9">
<createdBy>
<id>GOLswS44mh8</id>
<name>Tom Wakiki</name>
<displayName>Tom Wakiki</displayName>
<username>system</username>
</createdBy>
<lastUpdatedBy>
<id>GOLswS44mh8</id>
<name>Tom Wakiki</name>
<displayName>Tom Wakiki</displayName>
<username>system</username>
</lastUpdatedBy>
</user>
<!-- ... other users -->
</users>
CSV Response
Additionally, if you need the data in CSV format, you can use this API call:
https://play.im.dhis2.org/stable-2-40-4-1/api/39/users.csv?fields=id,createdBy,lastUpdatedBy&paging=false
The CSV response will contain the relevant fields in a tabular format, making it easy to import into Excel or other data processing tools.
Conclusion
Based on my tests, the createdBy
and lastUpdatedBy
fields are indeed returned correctly in JSON, XML, and CSV formats on the Play instance. If you’re not seeing the same results, it could be related to a specific configuration or issue with the version of DHIS2 you’re using. I would recommend testing on the Play instance to see if the issue persists.
Let me know if you need further assistance or if you’d like more details!
Best regards,