簡體   English   中英

HP ALM API:附加文件以通過 ALM REST API 運行步驟不起作用

[英]HP ALM API : Attaching file to run step through ALM REST API not working

我們使用 ALM REST API 獲取了運行步驟的詳細信息。 (參考ALM API 文檔

ALM 社區Community Microfocus ALM中提出了同樣的問題

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

並將運行步驟 ID 傳遞給以下 API,並嘗試使用 POST 和 PUT 附加文件。

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

我們收到 404 響應。 錯誤的請求。

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 狀態代碼

我認為您需要為 POST 請求使用以下 URL: https://some.almserver.com/qcbin/rest/domains/DOMAIN/projects/PROJECT/run-steps/<run-step-id>/attachments ://some.almserver.com/qcbin/rest/domains/DOMAIN/projects/PROJECT/run-steps/<run-step-id>/attachments (刪除/runs/<run-id>

更新:

這是一個從 Postman 生成的示例:

import requests

url = "http://xxx.xxx.xxx.xxx:8080/qcbin/rest/domains/DEFAULT/projects/demo/run-steps/1263/attachments"

payload="<file contents here>"
headers = {
  'Content-Type': 'application/octet-stream',
  'Slug': '1.jpg',
  'Cookie': 'JSESSIONID=<session>; ALM_USER=2e69...; LWSSO_COOKIE_KEY=PTKYM...; QCSession=MTQwM...; XSRF-TOKEN=3dfa4...'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

PS 我們正在開發用於將各種測試框架與 ALM 集成的商業平台,稱為Agiletestware Bumblebee ,因此您可能想看看它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM