User password reset through API

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 hannank@gmail.com

S hannan.khan.dhaka

B hannan-tech.blogspot.com

L https://bd.linkedin.com/in/hannankhan

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@gmail.com 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 hannank@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

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@gmail.com 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@gmail.com 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 hannank@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

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 hannank@gmail.com

S hannan.khan.dhaka

B hannan-tech.blogspot.com

L https://bd.linkedin.com/in/hannankhan

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@gmail.com 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@gmail.com 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.


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 hannank@gmail.com

S hannan.khan.dhaka

B hannan-tech.blogspot.com

L https://bd.linkedin.com/in/hannankhan

On Sat, Mar 31, 2018 at 8:21 AM, Hannan Khan hannank@gmail.com 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 hannank@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

Melaeke Serawit

BSc.Computer Engineering

Addis Ababa University
+251913090792

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 <hannank@gmail.com>, 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 hannank@gmail.com
S hannan.khan.dhaka
B hannan-tech.blogspot.com
L https://bd.linkedin.com/in/hannankhan

_______________________________________________
Mailing list: DHIS 2 developers in Launchpad
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : DHIS 2 developers in Launchpad
More help : ListHelp - Launchpad Help