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,500
Community Members
 
Community Events
165
Community Groups

Create issue with Affects Version/s field using Rest API

I am trying to create an issue using Rest API and affects version/s field is mandatory in our create issue screen. 

"versions":[
                    {
                        "id":"15911"
                     }
                 ],

Tried using the above mentioned syntax but I get this

error {"errorMessages":[],"errors":{"versions":"Version id '15911' is not valid"}} 

The id I used is from projectversion table,is that the right id? Also tried with name instead of id and got similar error.

{"errorMessages":[],"errors":{"versions":"Version name 'Example 1.3.1.4' is not valid"}}

How can Affect Version/s value be set? 

1 answer

1 accepted

1 vote
Answer accepted
Mohamed Riza Atlassian Team Sep 17, 2018

Hi @Sravya Vuggina

Can you please run the REST API call GET /rest/api/2/project/{projectIdOrKey}/versions for the project you are trying to create the issue in and verify if the version ID is present for this project. 

Hello @Mohamed Riza,

Thanks for your response! 

Ran the mentioned link to fetch the list of versions pertaining to the project I was working on and tried the same code - it worked! Earlier I was trying with a version of a different project. :)

Hello @Mohamed Riza @Sravya Vuggina 

Can you please guide me on how to set the affects version/s on Jira ticket using Rest api & json. I tried this "versions" : [{"name": "2022.0"}] but it doesn't work.FYI version 2022.0 is already added to the project. Below is the JSON I am using for Jira import. 

 

{ "projects": [

{ "name": "VIEW",

  "key": "VEW",

  "issues": [

     {

        "priority": "High",

          "status": "OPEN",

        "resolution": null,

        "issueType": "Defect",

        "summary": "[Documentation] = Extra arrow in help",  

        "assignee": "dbagul",

        "versions:" : [{"name": "2022.0"}],

        "created": "2019-02-01T16:05:52.13Z",

        "updated": "2022-03-02T00:34:16.903Z",

        "reporter": "dbagul",

        "components": [ "Documentation" ],

        "description": "!img_desc_2992_0.png!\n\n",

        "comments": []

 

        }

      ] 
   }
  ]
}       


Using above json I always get the below error during import. I have also tried "versions:" : ["2022.0"] and "Affects Version/s:": [ "Active Projects" ] but none of it works 
2022-05-05 23:25:32,704 ERROR - Failed to create data bean
java.lang.RuntimeException: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "versions" (Class com.atlassian.jira.plugins.importer.external.beans.ExternalIssue), not marked as ignorable
 at [Source: java.io.StringReader@6e0b1a2f; line: 13, column: 25] (through reference chain: com.atlassian.jira.plugins.importer.external.beans.ExternalProject["issues"]->com.atlassian.jira.plugins.importer.external.beans.ExternalIssue["versions"])

Looking forward to hearing from you, thanks! 

Suggest an answer

Log in or Sign up to answer
TAGS

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