javacucumberjira-rest-apijira-xray

Problem uploading a cucumber report to Xray Cloud


I have a problem uploadimg a cucumber report to xray cloud. Here is the code I use:

CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost postRequest = new HttpPost(UPLOAD_URL);
postRequest.setHeader("Authorization", "Bearer " + token);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("results", new FileInputStream(cucumberReport), ContentType.APPLICATION_OCTET_STREAM, cucumberReport.getName());
builder.addTextBody("info", testExecutionJson, ContentType.TEXT_PLAIN);
HttpEntity entity = builder.build();
postRequest.setEntity(entity);
HttpResponse response = httpClient.execute(postRequest);

The URL I use is this one: https://xray.cloud.getxray.app/api/v1/import/execution/cucumber/multipart

The Autorization is ok, I get the token in response to a prior query.

The TestExecution data I send is this:

{
    "fields": {
        "summary": "Upload Test",
        "issuetype": {
            "id": "10302"
        },
        "customfield_13906": "ENV1",
        "project": {
            "id": "21901"
        }
    },
    "xrayFields": {
        "environments": ["ENV1"],
        "testPlanKey": "IT-110958"
    }
} 

I get this response:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>503 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>

Does anyone see any obvious mistake in what I am doing?


Solution

  • Finally I switched to a simple result upload without creating an Execuction using https://xray.cloud.getxray.app/api/v1/import/execution

    that works fine and has the advantage that it uploads resukt by result and not a whiole report