Quantcast
Channel: DHIS2 Community - Latest topics
Viewing all articles
Browse latest Browse all 1855

Adding user to organisation unit

$
0
0

Hi there !

We are trying to add a user to an organisation unit using the API. We tried several different approaches, calling on URL:

/api/users/<my_user_id>?mergeMode=MERGE&importStrategy=CREATE_AND_UPDATE

PATCH

Patch is the action used by user management console, we we tried that one first.

Patch works fine, but replaces the existing list of orgUnit (we just want to add one) by the one we want to add.

Going for this solution would force us to make a GET call before this one to get the existing list of organisation units. It would also not be very secure in a multithreaded environment but that’s minor, so I’d like to avoid it if we can.

POST
"{"httpStatus":"Method Not Allowed","httpStatusCode":405,"status":"ERROR","message":"Request method 'POST' not supported"}"

I think this settles it.

PUT

we try to send this body:

{
    "organisationUnits": [
        {
            "id": "<my_orgunit_id>"
        }
    ],
    "dataViewOrganisationUnits": [
        {
            "id": "<my_orgunit_id>"
        }
    ],
    "teiSearchOrganisationUnits": [
        {
            "id": "<my_orgunit_id>"
        }
    ]
}

We also got an error stating:
“message”:“User needs to have at least one user role associated with it”,

We don’t want to change user roles or anything, so I’m not sure why we would want to have user roles in our payload. I’m afraid it’s asking for more info because it’s planning to replace the whole user.

Question

Can someone confirm what would be the best strategy for just assigning a user to a facility ?

Thanks a lot !

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1855

Trending Articles