Set password using the API

22 views
Skip to first unread message

Paul Smith

unread,
Jan 26, 2023, 10:58:02 AM1/26/23
to xnat_discussion
Hi,

I'm wondering whether it's possible to set a user's password via the User Management API, either when creating the user (via the API) or afterwards?

I'm using XNAT 1.8.6.1 and have site-wide Admin access.

Thanks for your help!

Paul

Charlie Moore

unread,
Jan 26, 2023, 11:11:06 AM1/26/23
to xnat_discussion
Hi Paul,

Indeed it is. Here's a curl example for doing it after the fact:
curl '$XNAT_URL/xapi/users/$TARGET_USER' -X PUT -H 'Content-Type: application/json' --data-raw '{"username":"$TARGET_USER","password":"$TARGET_PASSWORD"}'

And here's a curl example for creating a new [enabled, verified] account as an admin [which includes setting initial password]:
curl '$XNAT_URL/xapi/users' -H 'Content-Type: application/json' --data-raw '{"username":"$USERNAME","password":"$PASSWORD","firstName":"$FIRST","lastName":"$LAST","email":"$EMAIL","verified":true,"enabled":true}'

Thanks,
Charlie Moore

Paul Smith

unread,
Jan 26, 2023, 11:16:49 AM1/26/23
to xnat_discussion
Brilliant, thanks Charlie!

Cheers,
Paul

Reply all
Reply to author
Forward
0 new messages