Sharing DEs and other objects via the API

Hi Dhis2 Team,
I am trying to share a large number of data elements among st numerous user groups and it would be easier to bootstrap this via a script through the API, I am looking through the documentation and cannot find proper Payload syntax of sharing DES to multiple users. Any one who has done this before or atleast knows the syntax?

rgds

David

Hi David, you can find the docs here: https://dhis2.github.io/dhis2-docs/2.24/en/developer/html/dhis2_developer_manual_full.html#d7439e13183

···

On Wed, Jul 27, 2016 at 3:03 PM, David Muturi dnmuturi@gmail.com wrote:

Hi Dhis2 Team,
I am trying to share a large number of data elements among st numerous user groups and it would be easier to bootstrap this via a script through the API, I am looking through the documentation and cannot find proper Payload syntax of sharing DES to multiple users. Any one who has done this before or atleast knows the syntax?

rgds

David


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

David Huser
DHIS2 Support Specialist

dhuser@baosystems.com | https://baosystems.com | Skype: dafhus | 2900 K Street, Suite 404, Washington D.C. 20007

Hi

What version of DHIS2 are you on?

To share objects with a N number of user they would have to be put into their own user group, then all you have to do is to add:

“userGroupAccesses”: [

{“userGroup”: {“id”: “user-group-ID”}, “access”: “rw------” }

]

To the objects

(assuming read-write, r------- if not)

This would have to be sent to /api/23/metadata or /api/24/metadata (depending on which version you are on)

···

On Wed, Jul 27, 2016 at 3:03 PM, David Muturi dnmuturi@gmail.com wrote:

Hi Dhis2 Team,
I am trying to share a large number of data elements among st numerous user groups and it would be easier to bootstrap this via a script through the API, I am looking through the documentation and cannot find proper Payload syntax of sharing DES to multiple users. Any one who has done this before or atleast knows the syntax?

rgds

David


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

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

Many Thanks David,
Glad you have pointed the right chapter. I will proceed with generating the payload.

rds

David

···

2016-07-27 16:10 GMT+03:00 David Huser dhuser@baosystems.com:

Hi David, you can find the docs here: https://dhis2.github.io/dhis2-docs/2.24/en/developer/html/dhis2_developer_manual_full.html#d7439e13183

On Wed, Jul 27, 2016 at 3:03 PM, David Muturi dnmuturi@gmail.com wrote:

Hi Dhis2 Team,
I am trying to share a large number of data elements among st numerous user groups and it would be easier to bootstrap this via a script through the API, I am looking through the documentation and cannot find proper Payload syntax of sharing DES to multiple users. Any one who has done this before or atleast knows the syntax?

rgds

David


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

David Huser
DHIS2 Support Specialist

dhuser@baosystems.com | https://baosystems.com | Skype: dafhus | 2900 K Street, Suite 404, Washington D.C. 20007

Hi Morten,
This is on version 2.22, I am looking at the guide here http://dhis2.github.io/dhis2-docs/2.22/en/developer/html/dhis2_developer_manual_full.html

rgds

David

···

2016-07-27 16:12 GMT+03:00 Morten Olav Hansen morten@dhis2.org:

Hi

What version of DHIS2 are you on?

To share objects with a N number of user they would have to be put into their own user group, then all you have to do is to add:

“userGroupAccesses”: [

{“userGroup”: {“id”: “user-group-ID”}, “access”: “rw------” }

]

To the objects

(assuming read-write, r------- if not)

This would have to be sent to /api/23/metadata or /api/24/metadata (depending on which version you are on)

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Jul 27, 2016 at 3:03 PM, David Muturi dnmuturi@gmail.com wrote:

Hi Dhis2 Team,
I am trying to share a large number of data elements among st numerous user groups and it would be easier to bootstrap this via a script through the API, I am looking through the documentation and cannot find proper Payload syntax of sharing DES to multiple users. Any one who has done this before or atleast knows the syntax?

rgds

David


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

Ok, the problem with the approach mentioned there is that it can only change the sharing for 1 object at a time (the sharing API).

If you want to create/update a large number of objects including sharing, you will need to add the sharing to the object payload itself.

Since you are on 2.22, this means you have to use the old importer… and set sharing=true when doing the import.

···

On Wed, Jul 27, 2016 at 3:22 PM, David Muturi dnmuturi@gmail.com wrote:

Hi Morten,
This is on version 2.22, I am looking at the guide here http://dhis2.github.io/dhis2-docs/2.22/en/developer/html/dhis2_developer_manual_full.html

rgds

David

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

2016-07-27 16:12 GMT+03:00 Morten Olav Hansen morten@dhis2.org:

Hi

What version of DHIS2 are you on?

To share objects with a N number of user they would have to be put into their own user group, then all you have to do is to add:

“userGroupAccesses”: [

{“userGroup”: {“id”: “user-group-ID”}, “access”: “rw------” }

]

To the objects

(assuming read-write, r------- if not)

This would have to be sent to /api/23/metadata or /api/24/metadata (depending on which version you are on)

Morten Olav Hansen

Senior Engineer, DHIS 2

University of Oslo

http://www.dhis2.org

On Wed, Jul 27, 2016 at 3:03 PM, David Muturi dnmuturi@gmail.com wrote:

Hi Dhis2 Team,
I am trying to share a large number of data elements among st numerous user groups and it would be easier to bootstrap this via a script through the API, I am looking through the documentation and cannot find proper Payload syntax of sharing DES to multiple users. Any one who has done this before or atleast knows the syntax?

rgds

David


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