dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40694
Re: Updating the password of one user using PATCH in the Web API (2.20)
Hi Jose
When it comes to user credentials, it needs to be treated a bit
differently. What you probably have to do, is to basically include the full
payload of the old usercredentials with the new password. It does not
support matching on anything else than "user": { "id": "..." } which is
required. Please be aware that in 2.21, this field has been renamed
userInfo. I know its a bit weird that you have to point to the same user
that you are updating, but this is how the model currently is.
The code / username issue, in the usercredentials class the getCode
property has been overriden to be username, there is no real reason for it
(I think), but thats the reason you see this.
--
Morten
On Wed, Oct 7, 2015 at 9:05 PM, Jose Garcia Muñoz <josemp10@xxxxxxxxx>
wrote:
>
> Hi Morten, all,
>
> We need to update the passwords of several users using the Web API. We are
> trying the following API call:
>
> curl -X PATCH -d @file.json -u myuser:mypass
> http://localhost:8080/dhis/api/users/yhQ0Ma7CLNw/userCredentials -H
> "Content-Type: application/json"
>
> Where the json file is:
>
> {"username":"theuser", "name":"user name", "password":"thenewpassword",
> "code":"theuser","created":"2015-03-16T14:00:24.057+0000"}
>
> however I am getting the following message:
>
> {"httpStatus":"OK","httpStatusCode":200,"status":"OK","message":"Import
> was successful.","response":{"responseType":"ImportTy
>
> peSummary","status":"SUCCESS","importCount":{"imported":0,"updated":0,"ignored":1,"deleted":0},"type":"User","importConflicts
> ":[{"object":"theuser","value":"User is missing userCredentials part."}]}}
>
> Any ideas? Am I missing something?
>
> I have also noted, that this call
> http://localhost:8080/dhis/api/users/yhQ0Ma7CLNw/userCredentials.json is
> not returning the username field, but instead seems to be returned in the
> code??
>
> userCredentials:
> {
>
> - code: "theuser", //Shouldn't be username instead of code???
> - created: "2015-03-16T14:00:24.057+0000",
> - name: "Peter",
> - selfRegistered: false,
> - -..........................
>
>
> Many thanks for your help
>
> Best regards
> Jose
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help : https://help.launchpad.net/ListHelp
>
>
References