'XRay-Import json result file with Cloud Rest API call getting error "No project could be found with key 'null'."
We are trying to import test execution result in json format to xray Jira cloud by cloud Rest API call. After importing through Rest API call we are getting below error. I gone through the solutions but couldn't got working solution.
{"error": "Error retrieving Project from Jira with key "null": No project could be found with key 'null'."}
Below is my code snippet:
public void postAPICall(){
File dataFile = new File("src/main/resources/Payloads/auth.json");
String url ="https://xray.cloud.getxray.app/api/v2/authenticate";
RequestSpecification request = RestAssured.given();
request.header("Content-Type", "application/json");
request.body(dataFile);
Response response = request.post(url);
ResponseBody body = response.getBody();
tokenResult=body.asString();
}
@Test
public void postCallUpdateTestResult(){
postAPICall();
File jsonDataInFile = new File("src/main/resources/Payloads/SimpleExecutionResult.json");
String url ="https://xray.cloud.getxray.app/api/v2/import/execution?testExecKey=XX-XX";
RequestSpecification request = RestAssured.given();
request.header("Content-Type", "application/json");
request.header("Authorization", "Bearer "+tokenResult.substring(1,(tokenResult.length()-1)));
request.body(jsonDataInFile);
Response response = request.post(url);
ResponseBody body = response.getBody();
System.out.println(body.asString());
}
auth.json
{ "client_id": "XXXXXXXXXXXXXXXXXX", "client_secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
SimpleExecutionResult.json
{ "testExecutionKey": "XX-XX", "tests": [ { "testKey": "XX-XX", "status": "FAILED" }, { "testKey": "XX-XX", "status": "PASSED" } ] }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|