How do I change the Assignee using CURL - Jira Rest API

Charles Teague
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!
May 14, 2020

How do I change the Assignee using CURL - Jira Rest API?

 

I tried the following:
curl -D- -u "[email address]:[token]" -X PUT --data @@jqlassignuser.json -H "Content-Type: application/json" https://p97networks.atlassian.net/rest/api/2/issue/ACB-65/assignee > results.tx

 

where jqlassignuser.json contains the following:
{
"fields": {
"assignee": {
"name": "charles.teague"
}
}
}

 

Here are the results:
{"errorMessages":["Unrecognized field \"fields\" (Class com.atlassian.jira.rest.v2.issue.UserBean), not marked as ignorable\n at [Source: org.apache.catalina.connector.CoyoteInputStream@11835c39; line: 1, column: 14] (through reference chain: com.atlassian.jira.rest.v2.issue.UserBean[\"fields\"])"]}

 

1 answer

1 accepted

0 votes
Answer accepted
Charles Teague
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!
May 18, 2020

Changing the the json file to the following worked:

 

{"accountId": "557058:d166e0cb-9558-43a2-99ff-36636f97f02a"}

 I got the accountId by writing a .Net project in c# and used Atlassian.Net to query for an issue assigned to "charles.teague".  The accountId is in the issue.AssigneeUser.AccountId property, which was set when calling the following:

Jira jira = Jira.CreateRestClient(jiraData.Url, jiraData.UserName, jiraData.PasswordToken);
Issue issue = await jira.Issues.GetIssueAsync(issueKey);

with the following set:

  • string Url { get; set; } = @"https://[companyJiraUrl].atlassian.net";
  • string UserName { get; set; } = @"[jira email address]";
  • string PasswordToken { get; set; } = @"[Token you generated -- see https://confluence.atlassian.com/cloud/api-tokens-938839638.html";
  • issueKey is to the issue assigned to "charles.teague".
  • jira is from the Atlassian.Net NuGet package.

Note: You can delete the token when you are finished.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events