Update user email using REST API

I noticed that the API: (request PUT)

/rest/api/2/user?username=XXXXX

Body: {“emailAddress”: “mail@mail”}

does not work and returns error code 500.

Is this end point deprecated?

What API could I use instead?

We have a request from Jira Service Management that runs a job to update the mail for all users and so far it does not work.

Regards,
Marcelo

Hello @MarceloMS

You haven’t provided enough information to be able to help.

  1. Are you doing a PUT request to that endpoint?
  2. What are you putting in the body of the request?
  3. What version of Jira Server are you connecting to?
  4. Are you sure that version of Jira Server supports the Update User endpoint?

Are you 100% positive you’re connecting to a Jira SERVER instance, not Jira CLOUD. In Jira Cloud, the use of usernames and keys to identify users was deprecated ages ago. You must use the user’s accountId to identify them for all v2 and v3 REST API endpoints.

Hello @sunnyape

I answer your questions:

  1. Are you doing a PUT request to that endpoint?
    Yes, it is a PUT.

  2. What are you putting in the body of the request?
    {
    ** “emailAddress”: “mail@mail”**
    }

  3. What version of Jira Server are you connecting to?
    v8.20.11

  4. Are you sure that version of Jira Server?
    The job worked correctly for a long time, now it’s the problem.

Everything is about Server.

Can it be assumed the JSON in the body of the request uses plain double quote marks ("), not left and right quotation marks (“ and ”) as in your samples above?

A 500 error is an internal server error. It normally happens when you submit a mal-formed request with errant characters or bad structure.

Assuming that your Jira Server hasn’t recently been upgraded or changed, start by checking your code more thoroughly and comparing the current version with prior versions that were known to work. Try also testing that REST API endpoint with test tool like Postman to double check the fault.