It's all about the answers!

Ask a question

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?


Kirti Rawal (133) | asked Jan 10 '23, 5:55 a.m.

 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



permanent link
Ralph Schoon (63.1k33646) | answered Jan 10 '23, 10:29 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jan 10 '23, 10:29 a.m.

 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


Comments
Kirti Rawal commented Jan 11 '23, 2:16 a.m.

I have used the headers as headers as mentioned. It returns a slug ID. The slug id which is returned after post request

doesn't contain any attachments. It says the not found when you try to ping the url.


Ralph Schoon commented Jan 11 '23, 3:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I have provided what I can. Maybe someone else can? 

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.