Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,659
Community Members
 
Community Events
165
Community Groups

How do I set an Assignee on Issue Creation in the API?

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.

2 answers

0 votes
Alex Koxaras Community Leader Aug 04, 2021

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

Thanks, I'm familiar with the examples and am including the assignee in my request.

Like Dane Kantner likes this
Alex Koxaras Community Leader Aug 04, 2021

Then see if the assignee field is present on that issue type create screen. If not, add it on the screen.

I'm not sure what you mean by "screen".  

 

I'm working through python with the API so I don't see any screens.

Alex Koxaras Community Leader Aug 04, 2021

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).

The assignee field is present on the Create Issue screen with the user I'm working with the API with.

Alex Koxaras Community Leader Aug 04, 2021

Please post here your API command, as well as the issue create screen.

createIssue = {
"fields": {
"assignee": {
"name": "username"
},
}
}
issue = session.post('https://site.name/rest/api/2/issue', json=createIssue)

 

Capture.PNG

Alex Koxaras Community Leader Aug 04, 2021

So "username" is the actual name of the user?

Yes, I changed this value to something safe for public posting, but that value is the user's actual name.

Alex Koxaras Community Leader Aug 04, 2021

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.

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.  

Like Dane Kantner likes this

I'm seeing similar; works fine w/ an update after but not in a new issue create

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. 

Are you able to set the Assignee during issue creation in the UI, under the same identity you are using for the API?

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

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.  

The assignee field is present on the Create Issue screen with the user I'm working with the API with.

Like Dane Kantner likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,119 views 34 44
Read article

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