Versions Compared

Key

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

...

Code Block
languagejavascript
{
   "fields":{
      "customfield_10004":{
         "steps":[
            {
               "index":1,
               "fields":{
                  "action":"Step 1",
                  "data":"input Data 1",
                  "expected result":"Excepted result 1"
               },
               "attachments":[

               ]
            },
            {
               "index":2,
               "fields":{
                  "action":"Step 2",
                  "data":"input Data 2",
                  "expected result":"Excepted result 2"
               },
               "attachments":[

               ]
            },
            {
               "index":3,
               "fields":{
                  "action":"Step 4",
                  "data":"input Data 3",
                  "expected result":"Excepted result 3"
               },
            }
   "attachments":[

                  ]
            }
         ]
      }
   }
}
		


Currently, it's not possible to add attachments to steps at the moment of creation. This needs to be done afterward, using the proper endpoint described in Test Steps - REST.

Below is a full Test creation example using Jira's REST API endpoint for creating issues.

...

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": 01,
            	     "fields":{
	                    "action": "Step 1",
                	    "data": "input Data 1",
               	  	    "expected result": "Excepted result 1"
                    }
                },
                {
	                "index":2,
            	    "indexfields": 1,{
	                    "action": "Step 2",
                	    "data": "input Data 2",
                    		"expected result": "Excepted result 2"
					}
                      },
                },{
	                {"index":3,
               	     "indexfields": 2,{
	                    "action": "Step 3",
                	    "data": "input Data 3",
                	    "expected result": "Excepted result 3"
					}
                      },
                },{
	                {"index":4,
            	        "indexfields": 3,{
	                    "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)



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.

...