How to reset user password using RestAPI in Salesforce?

Monday, December 5, 2022
Avatar
iampankaj

I have Salesforce admin credentials and a password reset query. I want to reset the user password using Rest API. How to reset a user password using RestAPI in the Salesforce application? What is the password reset endpoint?

User Usr1 = [Select Id from User where username=
             'user1'];
System.setPassword(usr1.Id,'Test123');

 

1 Replies
Monday, December 5, 2022
Avatar
raj_89xx
re: iampankaj Monday, December 5, 2022

Users are treated as an sObject, so its the data api, so you access it at

https://<instance>.salesforce.com/services/data/v25.0/sobjects/User/<UserId>

and the password is at

https://<instance>.salesforce.com/services/data/v25.0/sobjects/User/<UserId>/password

https://<instance>.salesforce.com/services/data/v25.0/sobjects/User/<UserId>/password

To change a password using Curl Create a file with contents like these (it must be valid json), and save it somewhere.
 

{   

"NewPassword" : "myNewPassword1234"

}

then post to the service using a curl command like (fill in yourInstance, UserId, yourOAuthToken, and yourPasswdFile):

curl https://<yourInstance>.salesforce.com/services/data/v25.0/sobjects/User/<UserId>/password -H "Authorization: Bearer <yourOAuthToken>" —H "Content-Type: application/json" —d @<yourPasswdFile>.json —X POST

Theres more information and sample curl commands at

https://developer.salesforce.com/docs/atlas.en-

us.api_rest.meta/api_rest/dome_sobject_user_password.htm#!

I hope you got a lot of information in this answer. but still wanted to gain more information regarding this question then check out this link salesforce administrator training. This Training is for Beginners, Intermediate, and advanced Salesforce users to enhance their knowledge and understanding of the Salesforce CRM platform.

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Monday, December 5, 2022
  • Last Reply: Monday, December 5, 2022
  • Replies: 1
  • Views: 1079