Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

REST API - Change Project Lead

Matt Benett
Contributor
August 6, 2019

I am trying to change Project Lead by API, but I am getting the error:

 

{ "errorMessages": [ "Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@3e2799bc; line: 2, column: 5] (through reference chain: com.atlassian.jira.rest.v2.issue.project.ProjectInputBean[\"lead\"])" ]}

 

I am doing a PUT to here:

https://server/rest/api/latest/project/PROJKEY

 

Of this content:

{  "lead":  {  "key":"jsmith"  }  }

 

Any ideas please?

3 answers

1 accepted

1 vote
Answer accepted
Jack Nolddor _Sweet Bananas_
Atlassian Partner
August 6, 2019

Hi,

Use the following payload instead:

{"lead":"username"}

 

Here is a working example using cURL:

 

curl -X PUT http://localhost:8080/rest/api/2/project/PROJECTKEY -d '{"lead":"username"}' -u "admin:secret" -H "Content-Type: application/json" -vvv

 

Kind Regards

Matt Benett
Contributor
August 6, 2019

perfect, thank you.

Jack Nolddor _Sweet Bananas_
Atlassian Partner
August 7, 2019

You are welcome :)

Did my answer solves your problem?

If so, consider to mark the proposed solution as an 'Accepted answer'. This will help other people with the same or a quite similar problem to find a solution in a easy and faster way.


In addition, by doing this the post will automatically gain the "Solved:" prefix in search results to indicate other people that no further support is needed.

Kind Regards.

0 votes
Hossein Feshari
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 16, 2024

Using the REST API, I cloned a project, and the suggested answer with the payload {"lead", "username"} comes back with a success status of 200, but the UI does not show an update. So, I did a fetch after the update and observed the update took place as expected. Why UI does not show it remains a mystery until someone comes up with more details.

0 votes
Ricardo Antonio
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 27, 2022

Hello all.

The solution above doesn't work for me, at least using curl from Powershell. Doesn't matter what I do, I got an error (Unexpected character ('l' (code 108)):) this character is l of "lead". It means doesn't matter what I put after "-d", the first character, except the '{, will get this error.

Ok, let's go direct to the point. If you are stuck in PowerShell for this, follow what's worked for me (Powershell)

There is a Jira module for PowerShell, JiraPS, it has good commands to create issues, get information, and other functions you can check. But there are no commands for much other stuff. In this case, there is a special command, Invoke-JiraMethod. This basic process the rest API correctly in Powershell. To change the project lead, in my case is an offboarding scenario, so I want to deactivate the user, but we can't deactive a user that is a leader of a project. Using the same module, JiraPS:

Find projects that the user is leading:

$project_lead = Get-JiraProject | Where-Object {$_.LEAD -match "$user" }
$project_key = $project_lead.key

Then I use foreach to loop into the result to change the lead of all projects this user is leading.

basic the command is

$body = '{"lead": "$newlead_username"}'
$parameter = @{
Uri = "$(Get-JiraConfigServer)/rest/api/latest/project/$project_key" #$project_key is the project achronismus
Method = "PUT"
Body = $body
}
Invoke-JiraMethod @params

Finally, deactivate the user 

Set-JiraUser -User $user -Active $False

More information about JiraPS PowerShell module:

https://github.com/AtlassianPS/JiraPS

Suggest an answer

Log in or Sign up to answer