You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

上传Cucumber报告至Xray Cloud时遇503错误,求排查方案

上传Cucumber报告到Xray Cloud时遇到CloudFront 503错误

我在将Cucumber报告上传至Xray Cloud时遇到问题,授权验证正常,已通过前置请求获取到有效token。以下是相关信息:

使用的代码

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);

请求URL

https://xray.cloud.getxray.app/api/v1/import/execution/cucumber/multipart

发送的TestExecution数据

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

收到的响应

<!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>

可能的问题点及排查方向

  • "info"字段的Content-Type错误:当前用ContentType.TEXT_PLAIN发送TestExecution的JSON数据,但Xray Cloud要求该字段必须以application/json格式传递。修改代码中的addTextBody方法:
    builder.addTextBody("info", testExecutionJson, ContentType.APPLICATION_JSON);
    
  • 确认Multipart请求格式:显式设置MultipartEntityBuilder的Content-Type为multipart/form-data,确保请求格式符合Xray的要求:
    builder.setContentType(ContentType.MULTIPART_FORM_DATA);
    
  • 验证文件流有效性:确认cucumberReport指向的文件存在且可读,避免因文件无法读取导致请求异常。
  • 排查服务端临时故障:该503错误也可能是Xray Cloud侧的服务临时问题,可稍后重试请求,或确认Xray服务状态是否正常。

内容的提问来源于stack exchange,提问作者Jefe infiltrado

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 13:14:58