Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titlePOST /rest/api/2/issue
Panel
borderColor#ccc
borderStylesolid

Creates a Test in a project.

Request

Code Block
titleExample Input for Manual Test
{
    "fields": {
       "project":
       { 
          "key": "ABC"
       },
       "summary": "Sum of two numbers",
       "description": "example of manual test",
       "issuetype": {
          "name": "Test"
       },

       "customfield_10200": { "value": "Manual" },              
       "customfield_10004": {
            "steps": [
                {
	                "index":1,
            	    "fields":{
	                    "action": "Step 1",
                	    "data": "input Data 1",
               	  	    "expected result": "Excepted result 1"
                    }
                },
                {
	                "index":2,
            	    "fields":{
	                    "action": "Step 2",
                	    "data": "input Data 2",
                   		"expected result": "Excepted result 2"
					}
                },
                {
	                "index":3,
            	    "fields":{
	                    "action": "Step 3",
                	    "data": "input Data 3",
                	    "expected result": "Excepted result 3"
					}
                },
                {
	                "index":4,
            	    "fields":{
	                    "action": "Step 4",
                 	  	"data": "input Data 4",
                  		"expected result": "Excepted result 4"
					}
                }
            ]
        }
  
   }
}

where:

  • "customfield_10200" corresponds to the "Test Type" custom field (please check the correct customfield id for your Jira instance)
  • "customfield_10004" corresponds to the "Manual Test Steps" custom field (please check the correct customfield id for your Jira instance)
Code Block
titleExample Input for automated test (Cucumber Scenario)
{
    "fields": {
       "project":
       { 
          "key": "ABC"
       },
       "summary": "Sum of two numbers",
       "description": "example of cucumber automated test - Scenario",
       "issuetype": {
          "name": "Test"
       },
         
         
       "customfield_10200": { "value": "Cucumber" },
       "customfield_10201": { "value": "Scenario" },
       "customfield_10202": "Given I have a calculator\nWhen I press 1\nAnd I press +\nAnd I press 2\nAnd I press =\nThen I should see 3"  
  
   }
}

where:

  • "customfield_10200" corresponds to the "Test Type" custom field (please check the correct customfield id for your Jira instance)
  • "customfield_10201" corresponds to the "Cucumber Test Type" custom field (please check the correct customfield id for your Jira instance)
  • "customfield_10202" corresponds to the "Cucumber Scenario" custom field (please check the correct customfield id for your Jira instance)

 

Info
titleDeprecated since version 7.3.0

The Cucumber Test Type field is no longer displayed in the Test details panel. Xray now automatically detects whether a Test is a Scenario or a Scenario Outline. So, when creating a Test via API, it's also not necessary to pass this field value.

However, the field still exists and is automatically updated by Xray. This means you can continue to use it for filtering in JQL queries if needed.

If you're using a version prior to 7.3.0, the Cucumber Test Type field must be included. From version 7.3.0 onward, it’s no longer required.

 

Code Block
languagejs
titleExample Input for automated test (Generic)
{
    "fields": {
       "project":
       { 
          "key": "ABC"
       },
       "summary": "Sum of two number",
       "description": "example of generic test",
       "issuetype": {
          "name": "Test"
       },
         
         
       "customfield_10200": { "value": "Generic" },
       "customfield_10203": "sum_script.sh"  
  
   }
}

where:

  • "customfield_10200" corresponds to the "Test Type" custom field (please check the correct customfield id for your Jira instance)
  • "customfield_10203" corresponds to the "Generic Test Definition" custom field (please check the correct customfield id for your Jira instance)

    Tip
    titleExample Request

    curl -H "Content-Type: application/json" -X POST --data @test.json  -u admin:admin http://yourjiraserver/rest/api/2/issue

Responses

200 OK : text/plain : Successful. Returns a json.

Code Block
titleExample Output
{
    "id": "10700",
    "key": "ABC-53",
    "self": "http://127.0.0.1:8080/rest/api/2/issue/10700"
}

400 BAD_REQUEST : application/json : Returns the error.

401 UNAUTHORIZED : text/plain : Unauthorized request.

500  INTERNAL SERVER ERROR : text/plain : An internal error occurred.

...