How can a non jira admin can change his password through rest API service

/rest/api/2/myself/password
Methods: PUT
For the above api what are the input parameters need to pass?

If i use this API /rest/api/2/user/password?username=xxxx it is asking for admin permission.

Please help me how to solve this. Thanks.

Hello @janardhan.sree,

If the non-admin user is changing his/her own password, you can try this curl script

curl -i \
  --header "Content-Type: application/json" \
  --user guest:guest \
  --request PUT \
  --data '{"password":"newguestpassword","currentPassword":"guest"}' \
  http://localhost:2990/jira/rest/api/2/myself/password

The snippet above will let the non-admin user guest with current password guest change her/his password to newguestpassword.

Hope this helps.
Ian

I’m using JIRA Oauth based API on java application which seems like below

private HttpResponse getPutResponseFromUrl(OAuthParameters parameters, GenericUrl jiraUrl, String requestBody) throws IOException {
HttpRequestFactory requestFactory = new NetHttpTransport().createRequestFactory(parameters);
HttpRequest request = requestFactory.buildPutRequest(jiraUrl, ByteArrayContent.fromString(“application/json”, requestBody));// ostRequest(jiraUrl, ByteArrayContent.fromString(“application/json”, requestBody));
request.getHeaders().setContentType(“application/json”);
return request.execute();
}

String data = “{“password”:”" + newPassword + “”}";
JiraOAuthGetAccessToken oAuthAccessToken = getJiraOAuthGetAccessToken(getAccessToken(), getSecret(), JIRA_COMSUMER_KEY, JIRA_PRIVATE_KEY);
oAuthAccessToken.verifier = getSecret();
OAuthParameters parameters = oAuthAccessToken.createParameters();
response = getPutResponseFromUrl(parameters, new GenericUrl(“http://localhost:8080/jira/rest/api/2/myself/password”), data);

Please check out this to help. Thanks in advance!

Regards
Janardhan

I believe you need to have currentPassword in your request body.