It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Problems with changing assignee (REST API) Edited




curl -D- -u "$jira_user":"$jira_pw" -X PUT -H "Content-Type: application/json" https://$jira_server/rest/api/2/issue/$jira_key --data '{"fields": {"assignee":{"name":"$assignee"}}}'




[incle@incle jira]$ ./
HTTP/1.1 400 Bad Request
Server: nginx
Date: Tue, 04 Sep 2018 09:10:19 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-AREQUESTID: 1090x2941986x4
X-ASEN: SEN-2024910
Set-Cookie: JSESSIONID=63DEFAB473D458CFB183DFE55BFE8EC5; Path=/; HttpOnly
X-Seraph-LoginReason: OK
Set-Cookie: atlassian.xsrf.token=BSLJ-Y93F-8O6L-OULL|f95e7e2957b816674023cce36edb66d695e0f75d|lin; Path=/
X-AUSERNAME: yccheon
Cache-Control: no-cache, no-store, no-transform
X-Content-Type-Options: nosniff

{"errorMessages":[],"errors":{"assignee":"User '$assignee' does not exist."}}[incle@incle jira]$




I am worried about changing the assignment after creating JIRA.

I have since found an API for changing assignments
I made the following error message

Please solve the problem



1 answer

1 vote

Hello there!

I think the issue is that in Bash, everything inside single quotes is preserved literally, without exception, so you're basically sending the literal "$assignee" as the name of the assignee and not the actual variable value "yccheon".

I tried the workaround mentioned in stackoverflow, but I got a different error. The solution was to use double quotes in the payload and then escape the inside quotes("{\"name\":\"$assignee\"}").


curl -D- -u "$jira_user":"$jira_pw" -X PUT -H "Content-Type: application/json" https://$jira_server/rest/api/2/issue/$jira_key/assignee -d "{\"name\":\"$assignee\"}"

I also changed the API call to this "PUT /rest/api/2/issue/{issueIdOrKey}/assignee" because it's easier to use, the payload is simpler.

Kind regards,
Maurício Karas

Thank you for your reply.

But I still have not solved it.
I'm trying to create a new JIRA TIKET
I'm not trying to change the existing JIRA ASSIGNEE.

I want you to make ASSIGNEE to me (ASSIGNEE TO MEE) when I create a new JIRA.

Help me.

Then the API call should be "POST /rest/api/2/issue" and the payload can be something like the following:

"summary":"This is the Summary",
"description":"This is the Description",
"issuetype": {"name": "Task"},
"assignee": {"name": "yccheon"}
} }

 You can also send more information in the payload, check the REST API reference documentation for more details.

Unfortunately, with the REST API, you need to specify the username of the assignee, there's no way to have something similar to the "assign to me" in the GUI.

Kind regards,
Maurício Karas

Also, in this case, since the payload could be big, I recommend saving it in a ".json" file and your bash script can be like this:



curl -D- -u "$jira_user":"$jira_pw" -X POST -H "Content-Type: application/json" https://$jira_server/rest/api/2/issue -d @payload.json

The "@payload.json" is referencing the json file with the actual payload, this is good because it also avoids the single quote issue that you were having.

Kind regards,
Maurício Karas

Can you help me with setting assignee field in the web API. I do not know how exactly to fetch the names from the JIRA website for the assignee. i want to fetch those names from JIRA and then parse it on the web tool which talks to JIRA. It can fetch the version and the projects but not the list of the names of the assignee. I have tried the above solutions but somehow it doesnt work

Now neme of parameter is "accountId" insted of  "name".

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you