← Back to team overview

dhis2-devs team mailing list archive

Re: Assigning an Org. Unit Group to a Org. Unit with the API

 

Thanks Morten. It worked as you said. It will be nice to test it in 2.19,
as now I need to call the API n times if i need to add n orgunitgroups to
one orgunit.

Thanks for your quick answer.

On Sun, May 3, 2015 at 9:36 AM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
wrote:

> If you can use 2.18 or 2.19, you can use the collection API [1]. If you
> use 2.18, you -must- use the owning side, which means, add the orgUnit to
> the orgUnitGroup (and not the other way), in 2.19, you can do both.
>
> [1]
> https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s08.html#d5e1079
>
> --
> Morten
>
> On Sun, May 3, 2015 at 12:18 PM, Jason Pickering <
> jason.p.pickering@xxxxxxxxx> wrote:
>
>> Hi Jose,
>>
>> I think this was discussed recently here
>>
>> https://www.mail-archive.com/dhis2-devs@xxxxxxxxxxxxxxxxxxx/msg35136.html
>>
>> Regards,
>> Jason
>>
>>
>> On Sun, May 3, 2015 at 1:45 AM, Jose Garcia Muñoz <josemp10@xxxxxxxxx>
>> wrote:
>>
>>>
>>> Hi devs,
>>>
>>> So, I am trying to do it in one step (create the org.unit + assign one
>>> org. unit group) using the following API call:
>>>
>>> http://localhost:8080/dhis/api/organisationUnits
>>>
>>> and the payload:
>>>
>>> {
>>> "name":"The name",
>>> "shortName":"Short name",
>>> "parent":{
>>> "id":"wSkI02omzoJ"
>>> },
>>> "openingDate":"2015-03-03",
>>> "organisationUnitGroups": [
>>> {"id":"BW7NafIFfrS",
>>> "name":"Project",
>>> "created":"2014-11-18T15:56:01.136+0000",
>>> "lastUpdated":"2014-11-27T14:20:38.381+0000"}
>>> ]
>>> }
>>>
>>> However, although the org unit is created and we get a SUCCESS message,
>>> the org. unit group is not associated to the org. unit.
>>>
>>> Also I tried, in 2 steps (when the org unit is already in the system),
>>> something like this:
>>>
>>> API: http://localhost:8080/dhis/api/organisationUnitGroups/
>>>
>>> {
>>> "id":"BW7NafIFfrS",
>>> "organisationUnits":[{"id":"Tynta6mhuLQ"}]
>>> }
>>>
>>> But nothing happens
>>>
>>> Which is the best way to do this?
>>>
>>> Thanks
>>>
>>> Best regards
>>> Jose
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>>
>> --
>> Jason P. Pickering
>> email: jason.p.pickering@xxxxxxxxx
>> tel:+46764147049
>>
>> _______________________________________________
>> 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
>>
>>
>

References