← Back to team overview

dhis2-devs team mailing list archive

Re: [Dhis2-users] API for Patch dataSet and dataelement

 

Hi, try chanding the payload anf use dataSetElements instead of dataElements.

Also ensure you are using POST if you are adding dataElements to datasets.

Regards.

Sent from my HTC

----- Reply message -----
From: "Jean Habib" <habibjean18@xxxxxxxxx>
To: "Stephen Ocaya" <stephocay@xxxxxxxxxxxxxx>
Cc: "DHIS 2 Users list" <dhis2-users@xxxxxxxxxxxxxxxxxxx>, "DHIS 2 Developers list" <dhis2-devs@xxxxxxxxxxxxxxxxxxx>
Subject: [Dhis2-users] API for Patch dataSet and dataelement
Date: Sat, Apr 28, 2018 01:09

HI Ocaya for your reply.
But I got this error 
{
    "httpStatus": "Conflict",
    "httpStatusCode": 409,
    "status": "ERROR",
    "message": "Only identifiable object collections can be removed from."
}

What can be issue ?


2018-04-27 20:23 GMT+00:00 Stephen Ocaya <stephocay@xxxxxxxxxxxxxx>:
Hi, You might want to look at this documentation. This is a generic metadata update that you can make using the API for any metadata.
You will have to prepare your payload for dataElements as below:- where id is UID of existing dataElements and hit the endpoints using a comand like below

1. Prepare the Payload



{
"dataElements": [
{ "id": "ID1" },
{ "id": "ID2" },
{ "id": "ID3" }
]
}

2. Make the Call to the Endpoints



curl -d @dataelements.json "http://server/api/26/dataSets/UID/dataSetElements"; -X POST -H "Content-Type: application/json" -u user:password



https://docs.dhis2.org/2.28/en/developer/html/dhis2_developer_manual_full.html#webapi_adding_removing_objects_collections

regards


On Fri, Apr 27, 2018 at 8:45 PM, Jean Habib <habibjean18@xxxxxxxxx> wrote:

Hi all, 
Please there is a way to add dataeelement to dataset by API, like partial update ?

Best 



_______________________________________________

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

Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx

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

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





-- 
Stephen Ocaya
Health Information Systems Advisor,
Mobile: +256774558980 | +256752712007
SkypeID: stephocay











Strategic Information Systems for Actions
Plot 36 Impala Avenue, Kololo
P.O. Box 4750, Kampala