0

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" } ] }

  • This means that the project key was not found in the results submitted. The supported Json import are Xray Json, Behave Json or Cucumber Json, are you generating one of these? Please make sure in your replacements you are filling correctly the values. More info here: https://docs.getxray.app/display/XRAYCLOUD/Import+Execution+Results+-+REST#ImportExecutionResultsREST-ImportingExecutionResults – Cristiano Cunha May 06 '22 at 12:31
  • Can you please try to identify the project key on the JSON content? (not as query parameter) . See example at: https://github.com/Xray-App/xray-code-snippets/blob/main/use_cases/import_automation_results/python/xray_cloud.json – Sérgio May 06 '22 at 15:53
  • I am using Xray Json I added Project key in query perm with end point but still same error. Below is my URL. https://xray.cloud.getxray.app/api/v2/import/execution?testExecKey=XX-XX&projectKey=XX We Tried with below Json too but no luck { "testExecutionKey": "XX", "info" : { "project" : "XX" }, "tests": [ { "testKey": "XX", "status": "PASSED" }, { "testKey": "XXX", "status": "PASSED" }, { "testKey": "XXX", "status": "PASSED" } ] } – Clincher Sparton May 06 '22 at 15:59
  • It must be something with the issue keys. You may remove the "testExecutionKey" element on the json. You may try the code snippet that I shared earlier, change the keys to fit your use case. The format you shared seems fine. If your project key is "CALC", then use that for the "project" element. then for the tests, the "testKey" should be something like CALC-123 . – Sérgio May 06 '22 at 16:27
  • Were you able to solve it @ClincherSparton? – Sérgio May 10 '22 at 09:10
  • Yes below error is resolved after adding project key in json {"error": "Error retrieving Project from Jira with key "null": No project could be found with key 'null'."} But now new error while importing using Rest API i.e below {"error":"Test with key XX-XX not found."} – Clincher Sparton May 11 '22 at 06:33
  • do you have permissions to view the Test with that key in Jira? – Sérgio May 20 '22 at 11:58
  • @Sérgio Yes I have permission to view Test with the key in Jira. – Clincher Sparton May 23 '22 at 10:35

0 Answers0