Accessing DHIS2 trackedEntityInstances through the api endpoint does not return all attributes.
By default when you access the tracked entity instance for the first time, it returns only two attributes, fisrtName and Last Name.
When you edit the entity it now add the Unique ID, but still does not return gender.
When you change the gender, it does not show up when you call the endpoint.
But still is displayed on the UI
When you change the gender, it bring and error in the console saying.
Error: Failed to execute ‘get’ on ‘IDBObjectStore’: No key or key range specified.
Even you create new Instance, the gender attribute is not being returned even when you selected gender.
It looks like all attributes with drop downs are not returned through the api.
I used both the 2.30 and 2.31 demo servers.
I need to be able to return all attributes.
You are right that the endpoint will by default only return a limited set of tracked entity attributes. The attributes returned will be dependent on which attributes that is set to “display in list”. When asking for tracked entity instances in the context of a program, the programs tracked entity attribute settings is used. When asking in the context of a tracked entity type, the tracked entity attributes that is set in the tracked entity type will be used.
If the user has access to capture data in the organisation unit that owns the tracked entity instance, the endpoint also allows querying the other attributes that are not returned by default. This is done by adding url params:
attribute=(uid of attribute)
For adding several attributes:
attribute=(uid of attribute)&attribute=(uid of attribute)
The tracker app however should take care of all this - I was not able to reproduce the problem that is demonstrated by your screenshot. Can you make sure you clean the cache and retry - if the problem persists it would be great with some steps to reproduce it.
Best regards, Markus
However if I don’t know the uid of tracked entity Instances, I will not be able get all attributes.
And again passing or not passing the attribute will not affect the result, all attributes will be returned as I needed.
But now I want to filter tracked entity by attribute and return all attributes
For example this returns me what I need, I knew the tracked entity instance uid
However for the same entity only knew the firstName so filtered using firstName
No gender was returned.
Thank you so much @Markus . This saved me a lot. I spent hours, trying to see what’s going wrong, but finally hit this hint. Worked for me DHIS2 2.35