[keycloak-user] Update the user only with required fields
Chamantha De Silva
chamantha at outlook.com
Sun Jul 5 10:25:40 EDT 2015
Hi Stain,
I included a sample scenario as follows, in that I have updated only one field which is "enabled" field. But this is common for rest of the fields and attributes as well.
1. Before the update (test user's original information):
{
"id":"c2279ae4-99b7-403c-9ac7-0ff838ff1b83",
"username":"test-user",
"enabled":true,
"totp":false,
"emailVerified":false,
"firstName":"test",
"lastName":"user",
"email":"test-user at test.com",
"attributes":{
"locality":"Redwood city",
"country":"USA",
"region":"CA",
"postal_code":"94065",
"street":"Holly St"
},
"requiredActions":[
]
}
2. Update user as following :
Update user with just one field
API call : PUT /auth/admin/realms/leapset/users/test-user
Headers :
Accept: application/json
content-type: application/json
Authorization: Bearer TOKEN
Request body :
{"enabled":false}
After the update fields like email, firstname, lastname are missing
{
"id":"c2279ae4-99b7-403c-9ac7-0ff838ff1b83",
"username":"test-user",
"enabled":false,
"totp":false,
"emailVerified":false,
"attributes":{
"locality":"Redwood city",
"country":"USA",
"region":"CA",
"postal_code":"94065",
"street":"Holly St"
},
"requiredActions":[
]
}
> Date: Thu, 2 Jul 2015 02:26:51 -0400
> From: stian at redhat.com
> To: chamantha at outlook.com
> CC: keycloak-user at lists.jboss.org
> Subject: Re: [keycloak-user] Update the user only with required fields
>
> Send me the json you're updating with an what fields are changed and I'll look into it
>
> ----- Original Message -----
> > From: "Chamantha De Silva" <chamantha at outlook.com>
> > To: "Stian Thorgersen" <stian at redhat.com>
> > Cc: keycloak-user at lists.jboss.org
> > Sent: Friday, 26 June, 2015 7:18:08 AM
> > Subject: RE: [keycloak-user] Update the user only with required fields
> >
> > Hi Stain,
> >
> > Thank you for your response, we are using Keycloak 1.2.0 final and in that
> > version we do have that problem. If we update only particular element in
> > user update call it will truncate (turn to default values in some cases eg :
> > boolean).
> >
> > Best Regards,
> > Chamantha
> >
> > > Date: Thu, 25 Jun 2015 10:20:53 -0400
> > > From: stian at redhat.com
> > > To: chamantha at outlook.com
> > > CC: keycloak-user at lists.jboss.org
> > > Subject: Re: [keycloak-user] Update the user only with required fields
> > >
> > > You can just send the user json and only include the attributes you want to
> > > change.
> > >
> > > ----- Original Message -----
> > > > From: "Chamantha De Silva" <chamantha at outlook.com>
> > > > To: keycloak-user at lists.jboss.org
> > > > Sent: Thursday, 25 June, 2015 1:22:31 AM
> > > > Subject: [keycloak-user] Update the user only with required fields
> > > >
> > > > Hi Team,
> > > >
> > > > There are situations that we use update user rest API, to update just one
> > > > element of user (eg: enabled : false etc.) .
> > > > This requires a pre fetched user object from the GET user call, other
> > > > wise
> > > > rest of the user information tend to be truncated after the update call.
> > > >
> > > > Is there a possibility to update only specific elements of the user
> > > > instead
> > > > of sending whole the user object (objective is to avoid the GET call
> > > > right
> > > > before the update call and avoid possible tendency of data truncations )?
> > > > Your kind reply is highly appreciated.
> > > >
> > > > Best regards,
> > > > Chamantha
> > > >
> > > > _______________________________________________
> > > > keycloak-user mailing list
> > > > keycloak-user at lists.jboss.org
> > > > https://lists.jboss.org/mailman/listinfo/keycloak-user
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20150705/c3b2599b/attachment-0001.html
More information about the keycloak-user
mailing list