Unable to set date of birth using Tracker API

When I send the following API request, DHIS2 creates a Person instance successfully:

POST https://play.dhis2.org/2.33.1/api/trackedEntityInstances/
{
  "attributes": [
    {
      "attribute": "w75KJ2mc4zz",
      "value": "Zara"
    },
    {
      "attribute": "zDhUuAYrxNC",
      "value": "Zbigniew"
    },
    {
      "attribute": "iESIqZ0R0R0",
      "value": "1990-02-12"
    },
    {
      "attribute": "lZGmxYbs97q",
      "value": "5500304"
    }
  ],
  "orgUnit": "g8upMTyEZGZ",
  "trackedEntityType": "nEenWmSyUEp"
}

When I fetch the details of the instance, I can see that first name, last name and unique ID are set correctly, but date of birth (attribute “iESIqZ0R0R0”) is not included. What am I missing?

GET https://play.dhis2.org/2.33.1/api/trackedEntityInstances/wAHIGKLul8y
{
    "created": "2020-02-11T22:41:49.013",
    "orgUnit": "g8upMTyEZGZ",
    "createdAtClient": "2020-02-11T22:41:49.013",
    "trackedEntityInstance": "wAHIGKLul8y",
    "lastUpdated": "2020-02-11T22:41:49.013",
    "trackedEntityType": "nEenWmSyUEp",
    "lastUpdatedAtClient": "2020-02-11T22:41:49.013",
    "inactive": false,
    "deleted": false,
    "featureType": "NONE",
    "programOwners": [],
    "enrollments": [],
    "relationships": [],
    "attributes": [
        {
            "lastUpdated": "2020-02-11T22:41:49.019",
            "storedBy": "admin",
            "code": "MMD_PER_ID",
            "displayName": "Unique ID",
            "created": "2020-02-11T22:41:49.019",
            "valueType": "NUMBER",
            "attribute": "lZGmxYbs97q",
            "value": "5500304"
        },
        {
            "lastUpdated": "2020-02-11T22:41:49.017",
            "storedBy": "admin",
            "code": "MMD_PER_NAM",
            "displayName": "First name",
            "created": "2020-02-11T22:41:49.017",
            "valueType": "TEXT",
            "attribute": "w75KJ2mc4zz",
            "value": "Zara"
        },
        {
            "lastUpdated": "2020-02-11T22:41:49.018",
            "storedBy": "admin",
            "displayName": "Last name",
            "created": "2020-02-11T22:41:49.018",
            "valueType": "TEXT",
            "attribute": "zDhUuAYrxNC",
            "value": "Zbigniew"
        }
    ]
}
1 Like

Hi @nhooper,

This is expected behavior and it happens because your selected trackedEntityType doesn’t include the “Date of Birth” attribute. If you add the attribute to the trackedEntityType, it should be returned.

1 Like

Thank you very much @Gintare, that is very useful!

2 Likes