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

HP ALM API问题:通过ALM REST API为运行步骤附加文件失败

ALM REST API 为Run Step添加附件返回404错误

问题详情

已通过ALM REST API获取Run Steps详情,使用以下接口获取运行步骤:

https://some.almserver.com/qcbin/rest/domains/DOMAIN/projects/PROJECT/runs/<run-id>/run-steps

随后将Run Step ID传入以下接口,尝试通过POST和PUT方法上传附件:

https://some.almserver.com/qcbin/rest/domains/DOMAIN/projects/PROJECT/runs/<run-id>/run-steps/<run-step-ID>/attachments

但请求始终返回404错误。使用的Python代码如下:

URL =  "https://some.almserver.com/qcbin/rest/domains/DOMAIN/projects/PROJECT/runs/<run-id>/run-steps/<step-id>/attachments"
METHOD = "PUT"
HEADERS = {
    'cache-control': "no-cache",
    "Slug": "some.html",
    'Content-Type': "application/octet-stream"
}

def attach_to_run_step():
    f = open("/path/to/some.html", "rb")
    response = requests.put(URL, headers=HEADERS, cookies=cookies, data=f.read())
    print(response.content)

预期响应状态码为200,实际返回404。

排查与解决建议

  • 校验URL路径有效性:
    确认<run-id>和<run-step-ID>已替换为实际的数值ID,而非占位符。部分ALM版本不支持嵌套的run-steps/<id>/attachments路径,需改用独立的附件资源接口:

    https://some.almserver.com/qcbin/rest/domains/DOMAIN/projects/PROJECT/run-steps-attachments
    

    调用该接口时,需在请求体中传入run-step-id和run-id参数来关联目标步骤。

  • 调整请求方法与权限:
    ALM中新增附件默认使用POST方法,PUT仅用于更新已存在的附件。同时确认当前登录用户拥有Run Step的编辑权限及附件上传权限,权限不足可能返回404(而非403)。

  • 匹配ALM版本API规范:
    不同ALM版本的REST API路由存在差异,旧版本可能不支持Run Step级别的直接附件上传,需先获取Run Step实体,再通过其关联的附件端点操作。

  • 修正请求头参数:
    确保Slug头的文件名格式正确,Content-Type需与文件类型匹配——比如HTML文件可尝试使用text/html替代application/octet-stream。

  • 检查服务器路由配置:
    确认ALM服务器的qcbin路径配置正确,若存在反向代理或路径重写规则,可能导致嵌套路径无法被正确解析。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 04:25:09