API - update dataElement definitions

Dear all,

I am currently trying to change properties of existing DataElements via api
(esp. zeroIsSignificant). From the documentation I understand that I have to
read all significant metadata of the existing DataElement, change my property
and then push everything back via POST or PUT methods on
[/api/dataElements?strategy=UPDATE&mergeStrategy=MERGE] (Unfortunatly I can't
use the PATCH-method with my ETL tool)

Using this method, DHIS2 ignores the change, instead I get an importConflict
"Object already exists." in the result set.

Am I missing out on something?

Regards,

Uwe

Hi Uwe,

just to clarify, are you submitting data elements one by one or in bulk?

According to HTTP/REST principles, you need to use the PUT method when you update (not POST). Also, when you PUT, you need to put to the location of the resource. So:

POST to api/dataElements

PUT to api/dataElements/

Another approach is to submit everything in one payload to the api/metaData endpoint. If using XML you must wrap your payload in in that case.

https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s06.html

regards,

Lars

···

On Mon, Dec 7, 2015 at 8:24 AM, Uwe Wahser uwe@wahser.de wrote:

Dear all,

I am currently trying to change properties of existing DataElements via api

(esp. zeroIsSignificant). From the documentation I understand that I have to

read all significant metadata of the existing DataElement, change my property

and then push everything back via POST or PUT methods on

[/api/dataElements?strategy=UPDATE&mergeStrategy=MERGE] (Unfortunatly I can’t

use the PATCH-method with my ETL tool)

Using this method, DHIS2 ignores the change, instead I get an importConflict

“Object already exists.” in the result set.

Am I missing out on something?

Regards,

Uwe


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

Ok, that does it. Thanks for the clarification. Will be back for more soon :wink:

···

Lars Helge Øverland <larshelge@gmail.com> hat am 7. Dezember 2015 um 11:14
geschrieben:

Hi Uwe,

just to clarify, are you submitting data elements one by one or in bulk?

According to HTTP/REST principles, you need to use the PUT method when you
update (not POST). Also, when you PUT, you need to put to the location of
the resource. So:

POST to api/dataElements
PUT to api/dataElements/<uid-of-existing-dataelement>

Another approach is to submit everything in one payload to the api/metaData
endpoint. If using XML you must wrap your payload in in that
case.

https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s06.html

regards,

Lars

On Mon, Dec 7, 2015 at 8:24 AM, Uwe Wahser <uwe@wahser.de> wrote:

> Dear all,
>
> I am currently trying to change properties of existing DataElements via api
> (esp. zeroIsSignificant). From the documentation I understand that I have
> to
> read all significant metadata of the existing DataElement, change my
> property
> and then push everything back via POST or PUT methods on
> [/api/dataElements?strategy=UPDATE&mergeStrategy=MERGE] (Unfortunatly I
> can't
> use the PATCH-method with my ETL tool)
>
> Using this method, DHIS2 ignores the change, instead I get an
> importConflict
> "Object already exists." in the result set.
>
> Am I missing out on something?
>
> Regards,
>
> Uwe
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to : dhis2-users@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help : https://help.launchpad.net/ListHelp
>

--
Lars Helge Øverland
Lead developer, DHIS 2
University of Oslo
Skype: larshelgeoverland
http://www.dhis2.org <https://www.dhis2.org>