Creating Users through Account Invites using Web Api

Hi Morten, Abyot and other DHIS2 users,

I am trying to create users by sending User Account Invites through the web api but can’t find much in the way of documentation. Can anyone help?

I am using Version:2.16 Build revision:16384

Thanks.

Busoye

Hi Busoye,

The documentation, as you may have seen, is at

https://www.dhis2.org/doc/snapshot/en/user/html/dhis2_user_manual_en_full.html#d5e10755.

I agree that it should be expanded. Meanwhile, here are some additional tips: To see the format that you should send for a user invitation, try getting a user in json format through the API, such as:

https://apps.dhis2.org/demo/api/users/OYLGMiazHtW.json

You can use this as general ideas of what json to submit as the user invite. But you only need to submit a small subset of this. Note that for an invitation, the email address is essential. For example, the json file can contain something like:

{

“email”: "noreply@dhis2.org",

“userCredentials”: { “username”: “inviteduser” },

“groups”: [ { “id”: “wl5cDMuUhmF” }, { “id”: “QYrzIjSfI8z” } ],

“organisationUnits”: [ { “id”:“ImspTQPwCqd” } ]

}

Edit the email address to your own email for testing, and this json file should work with:

curl -d @user.jsonhttps://apps.dhis2.org/demo/api/users/invite” -H “Content-Type:application/json” -u admin:district -v

This will send an invitation for the user to register, with a preassigned user name of “invitedUser”. If you want the user to pick their own user name (like what they do when self-registering), you can leave out the “userCredentials” line. Note that as of now, user roles need to be assigned in a subsequent API call for the created user.

Hope this helps.

Cheers,

Jim

···

On Thu, Sep 4, 2014 at 7:33 AM, busoye@hisp.org wrote:

Hi Morten, Abyot and other DHIS2 users,

I am trying to create users by sending User Account Invites through the web api but can’t find much in the way of documentation. Can anyone help?

I am using Version:2.16 Build revision:16384

Thanks.

Busoye


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

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

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

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

Thanks Jim,

I was using dataviewOrganisationUnit in the call. Will try the just “organisationUnits”

Best regards,

Busoye

···

On Thu, Sep 4, 2014 at 7:33 AM, busoye@hisp.org wrote:

Hi Morten, Abyot and other DHIS2 users,

I am trying to create users by sending User Account Invites through the web api but can’t find much in the way of documentation. Can anyone help?

I am using Version:2.16 Build revision:16384

Thanks.

Busoye


Mailing list: https://launchpad.net/~dhis2-users
Post to : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help : https://help.launchpad.net/ListHelp

Hi Busoye,

Good. Assigning one or more organisationUnits is required. You may also optionally assign one or more dataViewOrganisationUnits.

Cheers,

Jim

···

On Thu, Sep 4, 2014 at 10:55 AM, busoye@hisp.org wrote:

Thanks Jim,

I was using dataviewOrganisationUnit in the call. Will try the just “organisationUnits”

Best regards,

Busoye

On 2014-09-04 16:34, Jim Grace wrote:

Hi Busoye,

The documentation, as you may have seen, is at

https://www.dhis2.org/doc/snapshot/en/user/html/dhis2_user_manual_en_full.html#d5e10755.

I agree that it should be expanded. Meanwhile, here are some additional tips: To see the format that you should send for a user invitation, try getting a user in json format through the API, such as:

https://apps.dhis2.org/demo/api/users/OYLGMiazHtW.json

You can use this as general ideas of what json to submit as the user invite. But you only need to submit a small subset of this. Note that for an invitation, the email address is essential. For example, the json file can contain something like:

{

“email”: "noreply@dhis2.org",

“userCredentials”: { “username”: “inviteduser” },

“groups”: [ { “id”: “wl5cDMuUhmF” }, { “id”: “QYrzIjSfI8z” } ],

“organisationUnits”: [ { “id”:“ImspTQPwCqd” } ]

}

Edit the email address to your own email for testing, and this json file should work with:

curl -d @user.jsonhttps://apps.dhis2.org/demo/api/users/invite” -H “Content-Type:application/json” -u admin:district -v

This will send an invitation for the user to register, with a preassigned user name of “invitedUser”. If you want the user to pick their own user name (like what they do when self-registering), you can leave out the “userCredentials” line. Note that as of now, user roles need to be assigned in a subsequent API call for the created user.

Hope this helps.

Cheers,

Jim

On Thu, Sep 4, 2014 at 7:33 AM, busoye@hisp.org wrote:

Hi Morten, Abyot and other DHIS2 users,

I am trying to create users by sending User Account Invites through the web api but can’t find much in the way of documentation. Can anyone help?

I am using Version:2.16 Build revision:16384

Thanks.

Busoye


Mailing list: https://launchpad.net/~dhis2-users
Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users
More help : https://help.launchpad.net/ListHelp