Thank you for your question, and welcome to the community!
Generally, to get an ID of a metadata object, you need to check its API endpoint, here are two important resources that will help you find your way through the API:
As for your situation, you’d need to get the dataSetId from the /api/dataSetID endpoint. Here’s an example where I specify the required fields to be dataSetId and dataSet name but I filter the results to only show the dataSetIds for a specific organisation unit:
@Gassim thanks for your guide. The link you mentioned is working for me. I just want to ask whether there is some DHIS2 Java Client to handle this request or I need to call it by using Java HTTP Client.
You’re welcome! If I understand your question properly then yes, if your Java client works as an API and can authenticate between itself and the instance then it should be okay to use it to connect to the DHIS2 API endpoints.
Just hitting something like InstanceURL/api/dataSets?fields=id,name should give you a clean list of dataset names with their IDs.
If you’re using the DHIS2 Java client, it should work as long as it can handle authenticated API calls. If not, you can always fall back on Java’s HTTP client to make the request and process the response. I’ve had to mix and match tools before, so don’t stress too much if the client doesn’t do everything you need.
Also, if you’re dealing with a lot of sensitive data, tools like idanalyzer.com can be handy for adding an extra layer of validation. I’ve found stuff like that useful when managing large datasets or ensuring things stay secure.