Create issue with Affects Version/s field using Rest API

Sravya Vuggina September 14, 2018

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
Atlassian Team members are employees working across the company in a wide variety of roles.
September 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. 

Sravya Vuggina September 17, 2018

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

Deepali Bagul May 5, 2022

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! 

aliva dash July 5, 2022

how did this got resolved?

Deepali Bagul July 6, 2022

@aliva dash Below JSON would work for the fix version and affected version as well. Hope this helps

 

{ "projects": [

{ "name": "VIEW",

  "key": "VEW",

  "versions": [
     {
        "name": "Active Projects"
     }

    ],

 

  "issues": [

     {

        "priority": "High",

          "status": "OPEN",

        "resolution": null,

        "issueType": "Defect",

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

        "assignee": "dbagul",

        "affectedVersions:" : ["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": []

 

        }

      ] 
   }
  ]
}       

Suggest an answer

Log in or Sign up to answer