#9360 session/json: CommandError
Closed: worksforme by abbra. Opened by yousif048.

Request for enhancement

Hello
I want to reset the password of users using the API, so that I can use this API call to in an intgration.

Issue

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 ~]#

Steps to Reproduce

  1. 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

  2. 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"}]}"

Actual behavior

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"}

Expected behavior

I should be able to reset the password successfully

Version/Release/Distribution

4.9.10

Additional info:

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.

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.

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)

Metadata