← Back to team overview

dhis2-devs team mailing list archive

Re: User password reset through API

 

Hello,
In that case from your error it seems that the user doesn't exist. First
make sure that the Id you use in the api end point is correct and the user
actually exists. (server/api/26/users/*userID). *

But for updating the password part, the following json actually works on
the demo server. using your curl script.

curl -X PUT -u admin:district -d @temp.json -H "Connection-Type:
application/json" https://play.dhis2.org/2.26/api/users/*USERID.json*


{
"id": "USERID",
"surname": "SURNAME",
"firstName": "FIRSTNAME",
"userCredentials": {
"id": "USER_CREDENTIAL_ID",
"username": "USER_N",
"password":"NEW_PASSWORD"
}
}



Sincerely,

On Sun, Apr 1, 2018 at 11:18 AM, Hannan Khan <hannank@xxxxxxxxx> wrote:

> Thanks Melaeke.
>
> My json payload exactly similar. Tried your orientation by get exactly
> same message.
>
>
>
>
>
> On Sun, Apr 1, 2018 at 2:09 PM, Melaeke Serawit <smelaeke22@xxxxxxxxx>
> wrote:
>
>> Hello,
>>
>> What kind of payload are you trying to send to the Server remember that
>> the password and the username are under userCredentials and not directly
>> under the user.
>>
>> so the payload should be like :
>>
>> {
>>
>> "userCredenttials":{
>>
>> "id": "userCredentialsID_of_the_user_(Separate from the userID)",
>>
>> "password":"the_new_password",
>>
>> "username":"userName"
>>
>> }
>>
>> }
>>
>> Hope this helps, if anything is unclear please feel free to ask.
>>
>> On Sat, Mar 31, 2018 at 8:21 AM, Hannan Khan <hannank@xxxxxxxxx> wrote:
>>
>>> Hello Experts
>>>
>>> Hope you are all enjoying Easter.
>>>
>>> I am trying to reset/update password through API. Is it possible to send
>>> PUT request with jason payload with only ID, username and password? I use
>>>
>>> curl -X PUT -u user:pass -d @u.json -H "Content-Type: application/json"
>>> https://server/api/26/users/ID
>>>
>>>  I am getting following error:
>>>
>>> {"httpStatus":"Conflict","httpStatusCode":409,"status":"ERRO
>>> R","message":"org.hisp.dhis.user.User does not exist: ID"}
>>>
>>> Please advice.
>>>
>>> Regards
>>> --
>>> Muhammad Abdul Hannan Khan
>>> Team Leader
>>> Support to the National HMIS
>>> MIS, Director General of Health Service
>>> Ministry of Health and Family Welfare
>>>
>>> T +880-2- 58816459 <+880%202-58816459>, 58816412 ext 118
>>> F +88 02 58813 875
>>> M+88 01819 239 241
>>> M+88 01534 312 066
>>> E hannank@xxxxxxxxx
>>> S hannan.khan.dhaka
>>> B hannan-tech.blogspot.com
>>> L https://bd.linkedin.com/in/hannankhan
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>>
>> --
>> Melaeke Serawit
>> BSc.Computer Engineering
>> Addis Ababa University
>> +251913090792 <+251%2091%20309%200792>
>>
>
>
>
> --
> Muhammad Abdul Hannan Khan
> Team Leader
> Support to the National HMIS
> MIS, Director General of Health Service
> Ministry of Health and Family Welfare
>
> T +880-2- 58816459 <+880%202-58816459>, 58816412 ext 118
> F +88 02 58813 875
> M+88 01819 239 241
> M+88 01534 312 066
> E hannank@xxxxxxxxx
> S hannan.khan.dhaka
> B hannan-tech.blogspot.com
> L https://bd.linkedin.com/in/hannankhan
>
>
>
>


-- 
Melaeke Serawit
BSc.Computer Engineering
Addis Ababa University
+251913090792

References