Question about api, org unit relationships

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 }

}

  1. could you please tell me what is the appropriate way?

Thanks,

Benjamin

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@bluesquarehub.com 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 }

}

  1. could you please tell me what is the appropriate way?

Thanks,

Benjamin


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

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

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

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

Hi Vlad,

Thanks for your answer. I actually had two questions:

1- get to know why some ways to add children to a parent do not work

2- get to know how to remove the parent association

Unfortunately I tried your suggestion for question 1 but I got a Http 500 as a response.

Best,

Benjamin

···

On 17 October 2017 at 13:45:40, Vladimer Shioshvili (vshioshvili@gmail.com) wrote:

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@bluesquarehub.com 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 }

}

  1. could you please tell me what is the appropriate way?

Thanks,

Benjamin


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

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

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

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