Date not getting updated via /api/events

Hi

I’m not sure if this is a regression or not, when was the last time this was working? I see from the code that it is validating against yyyy-MM-dd, which means only that pattern is supported, the value itself is just saved as a string in the database, so it must be the validation that is blocking.

Are you not getting any import summary back?

We could probably be a bit more lenient here, and try with DateUtils.SUPPORT_DATE_FORMATS (and then fallback to regex).

···

On Mon, Dec 8, 2014 at 6:03 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:

Hi,

When we POST the following payload to /api/events, data values of type Date are not getting updated on DHIS. Is this is a bug or something is wrong with the payload?

{

“events”: [

{
  "event": "a41f6a7588c",
  "program": "a625b2495e7",
  "programStage": "ab17f8e7729",
  "orgUnit": "ad6c0962e85",
  "eventDate": "2014-12-08",
  "dataValues": [
    {
      "dataElement": "a4e69b09a1a",
      "value": "2014-11-30T18:30:00.000Z"
    },
    {
      "dataElement": "a77963446a8",
      "value": "a64365ac185"
    },
    {
      "dataElement": "a7553cdaae8",
      "value": "a65ad0e22c5"
    },
    {
      "dataElement": "a1cdb7aadac",
      "value": "Case123"
    },
    {
      "dataElement": "a69359d5e25",
      "value": "P123"
    },
    {
      "dataElement": "a675c686c59",
      "value": "2014-12-30T18:30:00.000Z"
    },
    {
      "dataElement": "a1172eb93b0",
      "value": 34
    },
    {
      "dataElement": "a643ad95b6f",
      "value": "aa0fba11d29"
    },
    {
      "dataElement": "af42f25a82b",
      "value": "a6855a511fe"
    },
    {
      "dataElement": "a3f0a11a265",
      "value": "a10a1d53cff"
    },
    {
      "dataElement": "a3c9bac136b",
      "value": "a593e3e8d62"
    },
    {
      "dataElement": "a7ecd7e906c",
      "value": "a2e8ebc9c10"
    },
    {
      "dataElement": "a2065e605cb",
      "value": "a80dec2a6fd"
    },
    {
      "dataElement": "a7f4da5e70b",
      "value": "a1ee90caece"
    },
    {
      "dataElement": "a719e533d10",
      "value": "a431a48c6d0"
    },
    {
      "dataElement": "a6c00b468ab",
      "value": "2014-11-30T18:30:00.000Z"
    }
  ]
}

]

}


Morten

Yeah, this is to be expected. It only supports yyyy-MM-dd, which is the same as before, but I think maybe it ignored the rest of the string (the regex expects it to start and end with this pattern), looking at the comment for this code, it seems it was meant to be like this.

Abyot, are you completely ignoring the time dimension when sending events? Not sure if we need it? seems reasonable that we want to allow sending in ISO 8601 strings (not sure if we support dates in event analytics though?)

···

On Mon, Dec 8, 2014 at 9:26 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:

Not sure if this is regression. We have recently started POSTing to /api/events to DHIS trunk. So far, we were using the older build of DHIS.

Here’s the import summary. It says invalid date.

{

“imported”: 13,

“updated”: 0,

“ignored”: 3,

“importSummaries”: [

{
  "status": "SUCCESS",
  "dataValueCount": {
    "imported": 13,
    "updated": 0,
    "ignored": 3,
    "deleted": 0
  },
  "importCount": {
    "imported": 0,
    "updated": 0,
    "ignored": 0,
    "deleted": 0
  },
  "conflicts": [
    {
      "object": "a4e69b09a1a",
      "value": "value_not_valid_date"
    },
    {
      "object": "a675c686c59",
      "value": "value_not_valid_date"
    },
    {
      "object": "a6c00b468ab",
      "value": "value_not_valid_date"
    }
  ],
  "reference": "a41f6a7588c",
  "href": "[http://localhost:8080/api/events/a41f6a7588c](http://localhost:8080/api/events/a41f6a7588c)"
}

]

}


Morten

On Mon, Dec 8, 2014 at 4:51 PM, Morten Olav Hansen mortenoh@gmail.com wrote:

Hi

I’m not sure if this is a regression or not, when was the last time this was working? I see from the code that it is validating against yyyy-MM-dd, which means only that pattern is supported, the value itself is just saved as a string in the database, so it must be the validation that is blocking.

Are you not getting any import summary back?

We could probably be a bit more lenient here, and try with DateUtils.SUPPORT_DATE_FORMATS (and then fallback to regex).


Morten

On Mon, Dec 8, 2014 at 6:03 PM, Mahendra Kariya mahendra.kariya@thoughtworks.com wrote:

Hi,

When we POST the following payload to /api/events, data values of type Date are not getting updated on DHIS. Is this is a bug or something is wrong with the payload?

{

“events”: [

{
  "event": "a41f6a7588c",
  "program": "a625b2495e7",
  "programStage": "ab17f8e7729",
  "orgUnit": "ad6c0962e85",
  "eventDate": "2014-12-08",
  "dataValues": [
    {
      "dataElement": "a4e69b09a1a",
      "value": "2014-11-30T18:30:00.000Z"
    },
    {
      "dataElement": "a77963446a8",
      "value": "a64365ac185"
    },
    {
      "dataElement": "a7553cdaae8",
      "value": "a65ad0e22c5"
    },
    {
      "dataElement": "a1cdb7aadac",
      "value": "Case123"
    },
    {
      "dataElement": "a69359d5e25",
      "value": "P123"
    },
    {
      "dataElement": "a675c686c59",
      "value": "2014-12-30T18:30:00.000Z"
    },
    {
      "dataElement": "a1172eb93b0",
      "value": 34
    },
    {
      "dataElement": "a643ad95b6f",
      "value": "aa0fba11d29"
    },
    {
      "dataElement": "af42f25a82b",
      "value": "a6855a511fe"
    },
    {
      "dataElement": "a3f0a11a265",
      "value": "a10a1d53cff"
    },
    {
      "dataElement": "a3c9bac136b",
      "value": "a593e3e8d62"
    },
    {
      "dataElement": "a7ecd7e906c",
      "value": "a2e8ebc9c10"
    },
    {
      "dataElement": "a2065e605cb",
      "value": "a80dec2a6fd"
    },
    {
      "dataElement": "a7f4da5e70b",
      "value": "a1ee90caece"
    },
    {
      "dataElement": "a719e533d10",
      "value": "a431a48c6d0"
    },
    {
      "dataElement": "a6c00b468ab",
      "value": "2014-11-30T18:30:00.000Z"
    }
  ]
}

]

}