I was trying to send an attachment using the POST Request. I do not find the suitable headers to include in the requests. What headers should be included in the requests?
I am including the python program.
import requests
filepath ="D:\ETM\varaiblelist.txt"
#headers = {"Content-Type": "multipart/form-data; boundary=<calculated when request is sent>","Content-Length":"<calculated when request is sent>","Accept":"/", "Accept-Encoding":"gzip, deflate, br"}
headers = {"Content-Type": "multipart/form-data; boundary=<calculated when request is sent>","Content-Length":"<calculated when request is sent>"}
with open(filepath, 'rb') as fobj:
response = requests.post(url, headers=headers, files={'file': fobj},auth = HTTPBasicAuth('xxxxx', 'xxxxxx'), verify = False)
print(response.headers)'''
The result is as shown :
{'Date': 'Tue, 10 Jan 2023 08:05:14 GMT', 'X-Powered-By': 'Servlet/3.0', 'Strict-Transport-Security': 'max-age=31536000', 'Content-Location': 'slugxxxxxx', 'Location': 'https://jazz-test4.xxxx.xxx/qm1/service/com.ibm.rqm.integration.service.IIntegrationService/resources/xxxx/attachment/slugxxxxxx', 'Expires': 'Thu, 01 Dec 1994 16:00:00 GMT', 'Cache-Control': 'no-cache="set-cookie, set-cookie2"', 'Set-Cookie': 'JSA_SESSION_IDENTITY=xxxxx; Path=/qm1; Secure; HttpOnly; SameSite=None, JSESSIONID=xxxxxx; Path=/; Secure; HttpOnly; SameSite=None', 'Content-Length': '0', 'Keep-Alive': 'timeout=5, max=100', 'Connection': 'Keep-Alive', 'Content-Language': 'en-US'}
It gives response as 201. I use the url to check for the file. It says "File not Found".
One answer
In the documentation for ETM Reportable REST API the relevant headers are explained here:
Also consider to read https://jazz.net/forum/questions/280154/how-to-upload-file-using-rqm-reportable-rest-api all the answers, also the ones from the not accepted.
The Location header of the response should contain the URI of the attachment. Note that there are specific headers needed for the GET: https://jazz.net/wiki/bin/view/Main/RqmApi#HTTP_GET_Requests