2

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?

Stephen Ostermiller
  • 99,822
  • 18
  • 143
  • 364

1 Answers1

2

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"
  } ]
}
mortenoh
  • 21
  • 1