Hello I want to reset the password of users using the API, so that I can use this API call to in an intgration.
the issue is that I'm using curl at the moment to send the api request but I'm getting the following response {"result": null, "error": {"code": 905, "message": "unknown command 'session/json'", "data": {"name": "session/json"}, "name": "CommandError"}, "id": null, "principal": "admin@MYAWS.LOCAL", "version": "4.9.10"}[root@ipa ~]#
Get the session token using curl -v -H referer:https:///ipa -H "Content-Type:application/x-www-form-urlencoded" -H "Accept:text/palin" --cacert ca.crt --data "user=admin&password=" -X POST https://ipa.myaws.local/ipa/session/login_password
Try to reset the password with curl -X POST 'https:///ipa/session/json' -H referer:https:///ipa -H "Content-Type:application/x-www-form-urlencoded" -H "Accept:text/palin" --cookie "IPA Session" --cacert ca.crt --data "{"method":"user_mod/1","params":[["awstest"],{"userpassword":"", "version","2.251"}]}"
Got {"result": null, "error": {"code": 905, "message": "unknown command 'session/json'", "data": {"name": "session/json"}, "name": "CommandError"}, "id": null, "principal": "admin@MYAWS.LOCAL", "version": "4.9.10"}
I should be able to reset the password successfully
4.9.10
Any additional information, configuration, data or log snippets that is needed for reproduction or investigation of the issue.
Log file locations: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Linux_Domain_Identity_Authentication_and_Policy_Guide/config-files-logs.html Troubleshooting guide: https://www.freeipa.org/page/Troubleshooting
Can you show exact output from the second command? Your lines in the issue aren't exactly what should be because they contain typos like Accept:text/palin. It also has to be a different content type: Content-Type: application/json. You are sending wrong metadata and getting corresponding response.
Accept:text/palin
Content-Type: application/json
In general, the exact and correct payload can be seen in ipa -vvv user-mod awstest --password command's output. -vvv will dump both client sent data and server's response. I would also not use the ipa user-mod to change password but rather ipa passwd command, but this is irrelevant to your primary failure.
ipa -vvv user-mod awstest --password
-vvv
ipa user-mod
ipa passwd
Current IPA API references are available at https://freeipa.readthedocs.io/en/latest/api/index.html
Hello, Thank you, it was the Content-Type: application/json, once I've modified it, it worked.
Metadata Update from @abbra: - Issue close_status updated to: worksforme - Issue status updated to: Closed (was: Open)
closing.