It's all about the answers!

Ask a question

Seeking explanation and sample of attachment upload using REST API (RQM 3.0.1)

G S (5346) | asked Jul 05 '12, 11:48 p.m.

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:


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!


5 answers

permanent link
Pramod Chandoria (2.1k11220) | answered Jul 07 '12, 8:31 a.m.
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/<Project Area Name>/attachment/<any id you want to refer afterwards>
  • If a user wants to upload an attachment, -command is POST and user has to pass the complete path where the attachment is located as the -filepath argument tag and the URL reference (-url) where it needs to be uploaded.

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

permanent link
Ralph Schoon (61.5k33643) | answered Jul 06 '12, 3:13 a.m.
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:

permanent link
G S (5346) | answered Jul 08 '12, 7:52 p.m.

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.



permanent link
Prasun Roy (1673813) | answered Apr 25 '13, 3:44 p.m.
edited Apr 25 '13, 3:47 p.m.
 In order to Create an attachment you need to post the attachment to the URL 

For the exact code required for GET/PUT/POST refer to the RQMURLUtility.jar which you can download from the following link

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/<project Area>/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.

pankaj mishra commented Jul 30 '13, 8:35 a.m.

hi Prasun,
      Your comment was highly informative . But can the same thing be done using OSLC 2.0.
1.) How results can be uploaded to the RQM as attachment after executing the test script?

permanent link
Rahul Singh Bhadauriya (2821720) | answered Jul 30 '13, 8:40 a.m.
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.

Any pointers regarding this issue?


Your answer

Register or to post your answer.