← Back to team overview

dhis2-devs team mailing list archive

Re: Question about api, org unit relationships

 

Benjamin,

It looks like your goal is to change the parent. In that case this is the
PATCH format to use:

PATCH http://localhost:8080/api/organisationUnits/uwxbuyaEU2j/parent
{"parent":"hyAZBROiSX5"}


https://docs.dhis2.org/2.24/en/developer/html/dhis2_developer_manual_full.html#d7652e1702


Best,

Vlad

On Tue, Oct 17, 2017 at 5:01 AM Benjamin Roth <broth@xxxxxxxxxxxxxxxxx>
wrote:

> Hi,
>
> I have some questions about the API. For now I am using 2.24.
>
> I figured that to add a parent to an organisation unit, I have to PUT the
> child with parent field.
> 1) I wonder why PATCH does not work in this case:
> PATCH http://127.0.0.1:8080/api/organisationUnits/uwxbuyaEU2j {
>     "parent": { "id": "hyAZBROiSX5" }
> }
> or even
> POST
> http://127.0.0.1:8080/api/organisationUnits/hyAZBROiSX5/children/uwxbuyaEU2j
>
> ---
>
> Now, I can not find how to remove the parent/child relationship.
> I tried:
> DELETE
> http://127.0.0.1:8080/api/organisationUnits/hyAZBROiSX5/children/uwxbuyaEU2j
> DELETE
> http://127.0.0.1:8080/api/organisationUnits/uwxbuyaEU2j/ancestors/hyAZBROiSX5
> PUT  http://127.0.0.1:8080/api/organisationUnits/uwxbuyaEU2j {
>     "openingDate": "2016-12-30",
>     "name": "org unit2",
>     "shortName": "ou2",
>     "parent": { "id": null }
> }
> 2) could you please tell me what is the appropriate way?
>
> Thanks,
>
> Benjamin
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References