Seeking explanation and sample of attachment upload using REST API (RQM 3.0.1)
Hi,
I am using the REST API to create test cases, test runs etc. All that works fine but I am having trouble trying to upload an attachment using the REST API (I know the attachment is different). To do this, I need two things:
1. To upload the attachment :-) 2. To get the 'URL' of the attachment so I can associate it with a test case (but we'll ignore this for now) My questions are: 1. What URL do I use to upload the attachment? I see some samples that point to /jazz/secure/... and others that point to /qm/theproject/resources... It makes no sense to me at all. Where do the attachments live? Who gives the attachments its identity - us, when we upload? How do we do this? Given my project resources alias is: https://myserver:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/MyProject Can I please ask: what URL, exactly, would I use to upload a file called "something.txt"? 2. What method should I use? My assumption is that all I need to do is to use POST, pass in the bytestream of the attachment, and set the Content-Type to application/octet-stream. Is this correct? Incidentally, this method always succeeds but returns a zero length body and the Content-Location header is blank. Please ignore the URL Utility and RqmApi in your samples - I can practically recite them word for word. There is clearly something I am missing. Any help appreciated! G.S. |
5 answers
Hi @grahamodin
RQM URLUtility you should be able to upload attachment and the sample provided there is correct. Attachment upload --: -command POST -user <userid> -password <password> -filepath "Absolute full path of the file" -url https://<server>:9443/<context root qm or jazz>/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<Project Area Name>/attachment/<any id you want to refer afterwards>
Please let us know what is the problem in executing this command from URL utility. Ofcorse there is no plain REST API for attachment upload, but yes you can do GET and DETETE using REST API |
Ralph Schoon (63.5k●3●36●46)
| answered Jul 06 '12, 3:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I had a similar request for RTC recently. We were told that uploading of attachments is possible - the tools do it - but there is no easy way. We therefore decided to use the API.
Other similar questions without an answer also indicate that there probably is no easy solution today: https://jazz.net/forum/questions/65126/adding-attachement-using-oslc |
Thankyou for your replies. The RqmApi documentation page (which I can probably recite word for word now!) seems to imply that attachment uploads are just a POST with type of application/octet-stream - it seems that is not the case. I meant to say "ignore the RqmApi documentation page..." in my post above, not the RqmApi itself! API usage is exactly what I require. If anyone knows of a REST API sample that will upload and attachment and let me retrieve it, please let me know. GS
|
In order to Create an attachment you need to post the attachment to the URL
"https://<server>:9443/<context root>/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<project Area>/attachment/<Unique user defined ID>"
For the exact code required for GET/PUT/POST refer to the RQMURLUtility.jar which you can download from the following link https://jazz.net/wiki/bin/view/Main/RQMURLUtility
Once you have posted the attachment successfully RQM will return a HHTP status of 201 (Asset Created), then you can link the attachment URL that we used for posting to the Test Case. This can be achieved by first doing a GET on the Test case URL which will be of the form
"https://<server>:9443/<context root>/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<project Area>/testcase/urn:com.ibm.rqm:testcase:<Test case ID>" and once you have the XML for the Test case then update the <attachment> tag in the XML with the attachment URL.
And finally call PUT method and post the changes in Test case XML.
Comments
pankaj mishra
commented Jul 30 '13, 8:35 a.m.
hi Prasun,
|
Hi Prasun,
Thanks for your answer. II am using OSLC 2.0 REST API to attach the result files. I am able to add the attachement to the particular Execution Request from the Adapter. It gives me the 201 response and also the URI to access the uploaded attachment(s). But i am not able to link the attachements to the result execution section which you have explained here. Is this works with the RQM 4.0.X, OSLC 2.0 REST API ? I have tried the documentation from the following link to try the same but not able to do. https://jazz.net/wiki/bin/view/Main/RQMTestAutomationAdapterAPI Any pointers regarding this issue? Thanks Rahul |
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.