You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I want to be able to set the assignee for issues when I create them via the API.
However, whatever info I send results in the same error: Field 'assignee' cannot be set. It is not on the appropriate screen, or unknown
I do know there's an API endpoint for assigning to known tickets, however, I need to perform this action on issue creation, and that's not working.
OK, for all the Python people that arrive here after, here is how I've accomplished getting user id's emails and names so I can assign tickets to them.
def get_assignable_users(start_from):
auth, headers, base_url = auth_and_headers()
url = f"{base_url}/rest/api/3/user/assignable/search"
query = {
'project': 'ONE OF YOUR PROJECT KEYS',
'startAt': start_from
}
response = requests.request(
"GET",
url,
headers=headers,
params=query,
auth=auth
)
return response
if __name__ == "__main__":
start = 0
my_json = {}
while start is not None:
user_list_response = get_assignable_users(start)
text = json.loads(user_list_response.text)
for user in text:
my_json[f"{user['emailAddress']}"] = user['accountId']
if len(text) == 100:
start = start + 100
else:
start = None
with io.open('json_users.json', 'w') as outfile:
json.dump(my_json, outfile)
The outputted json_users file can be imported into your script and queried by email address to get the id.
Hi @Joe Osborne
Did you take a look at these examples? https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/
If assignee is a mandatory field, then you have to include it in your API.
Let me know if the above helps.
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, I'm familiar with the examples and am including the assignee in my request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then see if the assignee field is present on that issue type create screen. If not, add it on the screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure what you mean by "screen".
I'm working through python with the API so I don't see any screens.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you might work with python, but "screens" is a Jira essential feature.
When you create an issue/ticket on Jira, a popup screen appears, which prompt you to complete certain fields (mandatory and optional). Screens can also be used on workflow transitions. Screens are also used when a user creates, view or edit an issue. So even if you don't see any screen, they do exist.
With that said, you have to check if the assignee field is present on the creation screen. If not, then you have to add it. If you are not a jira admin, then you have to inform a jira admin to add this field to the creation screen of the project of the issue type you are trying to create.
Sorry to tell you that, but screens, field, schemes etc are Jira basic terminology and you should start to get accustom with them (even if you use REST API).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The assignee field is present on the Create Issue screen with the user I'm working with the API with.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please post here your API command, as well as the issue create screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
createIssue = {
"fields": {
"assignee": {
"name": "username"
},
}
}
issue = session.post('https://site.name/rest/api/2/issue', json=createIssue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So "username" is the actual name of the user?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I changed this value to something safe for public posting, but that value is the user's actual name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok then. Can you take a look at this post https://community.atlassian.com/t5/Jira-questions/Jira-REST-API-getting-error-unable-to-create-an-issue-using/qaq-p/1399628
It seems that another was facing the same issue with you. It could be that the main problem could be that are using fields' names instead of identifiers. Give it a try and let me know if that worked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, but I noted this post already. Their problem was malformed requests, which I think is ok as it's working in the assignee endpoint.
Strangely it doesn't work with new issue creation though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm seeing similar; works fine w/ an update after but not in a new issue create
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For those who come here later: I was able to get this to work with
"assignee": {"id":"62abc....501ee"}
I found the required ID by exporting to XML an issue with the correct user assigned.
Also suggested elsewhere that accountid instead of id might work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you able to set the Assignee during issue creation in the UI, under the same identity you are using for the API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can successfully assign an assignee using the assignee endpoint:
PUT /rest/api/2/issue/{issueIdOrKey}/assignee
However, when I include the same request on a ticket creation request, I get the error mentioned above: Field 'assignee' cannot be set. It is not on the appropriate screen, or unknown
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am asking if you can set the Assignee field during issue creation when you use the web UI and the same identity you use for the API.
Is the destination project for the new issue a Team Managed project or a Company Managed project?
Try logging into the Jira web application with the identity you use for your API call. Try using the UI to create an issue in the desired project. Is the Assignee field available there?
If the Assignee field is not available in the Create Issue UI screen for your project and the issue type you are trying to create, then you will not be able to set the value using the Create Issue API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The assignee field is present on the Create Issue screen with the user I'm working with the API with.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.