1

We have fetched Run Steps details using ALM REST API. (for reference ALM API Documentation

Same question is being asked in ALM community, Community Microfocus ALM

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

and passed Run Step id to below API and tried to attach file using POST and PUT.

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

we are getting 404 response. Bad request.

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)

Expected : 200 response Actual : 404 status code

dmairpad
  • 13
  • 3
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 15 '22 at 07:46

1 Answers1

1

I think you need to use the following URL for your POST request: https://some.almserver.com/qcbin/rest/domains/DOMAIN/projects/PROJECT/run-steps/<run-step-id>/attachments (remove /runs/<run-id>)

Update:

Here is an example, generated from 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)

P.S. We are developing commercial platform for integrating various test frameworks with ALM, which is called Agiletestware Bumblebee, so you might want to have a look at it.

Sergi
  • 990
  • 5
  • 16
  • Thank you. It worked fine. Could you also help us to upload attachment through URL using REST API. In the UI we could see Attach URL option. We need request payload, headers ,method for the same. – dmairpad Dec 15 '22 at 10:03
  • @dmairpad, I've updated my answer with the example generated from my Postman request (I'm not a Python expert :)). P.S. we are developing commercial integration platform for ALM called Bumblebee (https://agiletestware.com/bumblebee), you might want to have a look at it. – Sergi Dec 15 '22 at 11:08