Mobile app version of vmapp.org
Login or Join
Harper822

: Error while creating a new user through web api (Dhis2.25) Error : attempted to assign id from null one-to-one property [org.hisp.dhis.user.UserCredentials.userInfo]" Payload I am using: Payload:

@Harper822

Posted in: #Dhis2

Error : attempted to assign id from null one-to-one property [org.hisp.dhis.user.UserCredentials.userInfo]"


Payload I am using:

Payload: {
"firstName": "John",
"surname": "Doe",
"email": "johndoe@mail.com",
"userCredentials": {
"username": "johndoe",
"password": "your-password-123",
"userRoles": [ {
"id": "Euq3XfEIEbx"
} ]
},
"organisationUnits": [ {
"id": "ImspTQPwCqd"
} ],
"userGroups": [ {
"id": "vAvEltyXGbD"
} ]
}


Why is this happening on 2.25 build revision edc697d?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Harper822

1 Comments

Sorted by latest first Latest Oldest Best

 

@Michele947

For this to work properly (currently) you need to generate an ID (/api/system/id) and then modify the payload like this:

{
"id": "generated-id",
"firstName": "John",
"surname": "Doe",
"email": "johndoe@mail.com",
"userCredentials": {
"userInfo": { "id": "generated-id" },
"username": "johndoe",
"password": "your-password-123",
"userRoles": [ {
"id": "Euq3XfEIEbx"
} ]
},
"organisationUnits": [ {
"id": "ImspTQPwCqd"
} ],
"userGroups": [ {
"id": "vAvEltyXGbD"
} ]
}

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme