Error changing user password through REST

Ole-André Rodlie August 11, 2016

Hi,

So I'm trying to change a users password through the REST api using the admin user, but whatever I try I get a error message saying that I need to supply 'username' and 'key'.

Example:

curl -D- -u admin:password -X PUT --data "{\"username\":\"a_user\",\"key\":\"new_password\"}" -H "Content-Type: application/json" https://SITE.atlassian.net/rest/api/2/user/password

The result:

HTTP/1.1 404 Not Found
Server: nginx
Date: Fri, 12 Aug 2016 09:13:33 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-AREQUESTID: 673x673x1
X-ASEN: SEN-7908132
X-Seraph-LoginReason: OUT
X-Seraph-LoginReason: OK
X-ASESSIONID: 93wtdc
X-AUSERNAME: admin
X-ATENANT-ID: XXXXXXXXXX.atlassian.net
Cache-Control: no-cache, no-store, no-transform
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID=XXXXXXXXXX; Path=/; Secure; HttpOnly
Set-Cookie: studio.crowd.tokenkey=""; Domain=.XXXXXXXXXX.atlassian.net; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
Set-Cookie: studio.crowd.tokenkey=XXXXXXXXXX; Domain=.XXXXXXXXXX.atlassian.net; Path=/; Secure; HttpOnly
Set-Cookie: atlassian.xsrf.token=XXXXXXXXXX; Path=/; Secure

{"errorMessages":["Either the 'username' or the 'key' query parameters need to be provided"],"errors":{}}

 

I get the same error using PHP or any other language. The username is correct, and I know the server parses the JSON.

1 answer

1 accepted

1 vote
Answer accepted
Peter Geshev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 11, 2016

Hi Ole,

I think that you should send 

{\"password\":\"new_password\"}

instead and you should query https://SITE.atlassian.net/rest/api/2/user/password?username=a_user&key=a_user_key

Regards,

Petar

Ole-André Rodlie August 12, 2016

Ahh, of course. I though username/key had to be in the json. It now works (I didn't use key, just username).

 

Thanks

Michael Angelo Timoteo November 8, 2018

I am trying to do this but I am getting 415 Unsupported Media type using postman. Can you share me your postman configuration?

David Fitzjarrell June 27, 2019

Did this change?

I am receiving a 404 as well:

curl -i -X PUT -u admin:apiKey -H "Content-Type: application/json" -d '{"passord": "<newPassword>"}' "https://<mySite>.atlassian.net/rest/api/latest/user/password?username=<userName>&key=<userName>"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events