Re: [Dhis2-devs] User password reset through API

2018-04-03 Thread Hendrik de Graaf
Hi Muhammad,

Make sure you include the `userCredentials.id` field in your PUT request too. 
That should be enough for updating a user.

However, when you want to set fields for a new user (POST request), you must 
make sure to also to create a `userCredentials.userInfo.id` field.

You can use the d2 `generateUid` method ( 
http://dhis2.github.io/d2/module-uid.html#.generateUid) to generate a uuid on 
the client.

Good luck,
Hendrik


On 31 Mar 2018, 17:21 +0200, Hannan Khan , 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":"ERROR","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, 58816412 ext 118
> F +88 02 58813 875
> M+88 01819 239 241
> M+88 01534 312 066
> E hann...@gmail.com
> 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@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help : https://help.launchpad.net/ListHelp
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] User password reset through API

2018-04-01 Thread Melaeke Serawit
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  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 
> 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  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 hann...@gmail.com
>>> 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@lists.launchpad.net
>>> 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 hann...@gmail.com
> 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
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp


Re: [Dhis2-devs] User password reset through API

2018-04-01 Thread Melaeke Serawit
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  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":"
> ERROR","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 hann...@gmail.com
> 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@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>


-- 
Melaeke Serawit
BSc.Computer Engineering
Addis Ababa University
+251913090792
___
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp