Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

creating a xray test execution via HTTP Rest Api

Tony Tay
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 10, 2022

Hi all

I am trying to automatically create a Xray Test Execution.

Will appreciate some help as to how to go about doing it.  This is my first attempt at creating a Xray Test Execution automatically via rest api.

This is the snapshot of the code sending the HTTP Post request

public String BasicAuthPostRequest(String baseURI, String resource, String jsonStr, String username, String password) {
RestAssured.baseURI = baseURI;
RequestSpecification request = RestAssured.given().contentType(ContentType.JSON).auth().preemptive().basic(username, password)
.body(jsonStr);
Response resp = request.post(resource);
String returnStr = (resp.getStatusCode() == 200) ? resp.getBody().prettyPrint() : null;
return returnStr;
}

The body (jsonStr) is:

{"fields":{"project":{"key":"XPPS"},

"summary":"WSS WatchList Test Execution Suite",

"description":"Automated Test Execution Suite Creation",

"issueType":{"name":"Xray Test Execution"}}

}

The resource is: 

"/rest/api/2/issue/"

Response from jira server after sending is:

 11:39:38.606 [main] DEBUG o.a.h.i.conn.DefaultClientConnection - Receiving response: HTTP/1.1 400 Bad Request
11:39:38.606 [main] DEBUG org.apache.http.headers - << HTTP/1.1 400 Bad Request
11:39:38.606 [main] DEBUG org.apache.http.headers - << x-arequestid: 699x28927049x6
11:39:38.606 [main] DEBUG org.apache.http.headers - << x-anodeid: jira-2
11:39:38.606 [main] DEBUG org.apache.http.headers - << referrer-policy: strict-origin-when-cross-origin

 

1 answer

1 accepted

0 votes
Answer accepted
Tony Tay
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 11, 2022

Okay. I found the issue.  IssueType should be all lowercaps.  Worked after that

Suggest an answer

Log in or Sign up to answer