How to create JIRA with REST API and "Environment(s) Affected" field

We're trying to use the JIRA REST API to create issues on a project.  Below is the command and JSON we're using.  Keep getting a 400 error saying: 

{"errorMessages":[],"errors":{"Environment(s) Affected":"Field 'Environment(s) Affected' cannot be set. It is not on the appropriate screen, or unknown."}}

Any suggestions how we can get the command to run successfully?  The Environment(s) Affected field is a multi-selection field.

 

curl -i -D- -u 'user:pass' -X POST -d @./create_issue.json -H "Content-Type: application/json" https://jira.example.com/rest/api/2/issue/

 

$ cat create_issue.json
{
        "fields": {
                "project":
                {
                        "key": "TEST"
                },
                "summary": "TEST Issue Creation",
                "description": "Testing JIRA integration. Ticket can be closed.",
                "Environment(s) Affected": "None",
                "issuetype": {
                        "name": "Incident"
                }
        }
}

 

screenshot.jpg

 

 

1 answer

1 accepted

0 votes
Josh Steckler Community Champion May 15, 2017

Hi Doug,

Since "Environment(s) Affected" is a custom field, you will need to refer to it using the "customfield_1234569" notation rather than the field name. Only system fields can be referred to by name. To find the ID for your custom field, you can either pull the createmeta or look in your custom field management page and see the ID in the URL when you're modifying that particular field.

Look for the heading "Example of creating an issue using custom fields" on this page. https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue

Thanks, Josh.  I just tried using the custom field ID and it did work before your answer came in.  Wasn't aware custom fields had to be referenced by the ID.  Wish the error messaging returned would be improved to mention that. 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,963 views 12 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot