Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get the attachment id of an attachment uploaded using REST API

 I have uploaded an attachment using RQMURL utility using command - java -jar RQMUrlUtility.jar -command POST -user <myid> -password <mypath> -filepath "C:\\Users\\libin\Desktop\\abcd.txt" -url "https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<project Area>/attachment/<user defined id>"

Attachment is uploaded successfully.But RQM has created a new id for the attachment and hence i am not able to link the attachment to my test case or test results.Is there any way to get the id  assigned by RQM so that i can link it with execution results?

0 votes


Accepted answer

Permanent link
Hi Libin,

I have followed the suggestion from Paul to issue the GET command in Poster:

GET on https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/RQMDemo/attachment

It returns the new attachment id from above GET command:

<entry xmlns="http://www.w3.org/2005/Atom"><id>https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/RQMDemo/attachment/urn:com.ibm.rqm:attachment:31</id><updated>2015-09-21T14:36:27.141Z</updated><title type="text">jazz-mark.png</title><summary type="text">Attachments Section</summary><link href="https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/RQMDemo/attachment/urn:com.ibm.rqm:attachment:31" rel="alternate" type="application/xml" title=""/>
</entry>

Hope this helps!

Will
libin sebastian selected this answer as the correct answer

0 votes

Comments

 Hi William,

 Thanks for your update.I tried a GET using the below command -
 java -jar RQMUrlUtility.jar -command GET -user <myid> -password <mypaswd> -filepath I:\Java\junk\ -url "https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/Demo%20(Quality%20Management)/attachment"

i got the below response -
RQMUrlUtility: Connected to https://localhost:9443 using project "Demo+(Quality+
Management)"
RQMUrlUtility: Calling [ HTTP GET ] method to download an attachment
RQMUrlUtility: Server Response code: 200
RQMUrlUtility: Got an IOException: java.io.FileNotFoundException: I:\Java\junk\M
on, 21 Sep 2015 17:43:15 GMT (The filename, directory name, or volume label synt
ax is incorrect)
 
Directory  I:\Java\junk\ is there in the system.Am i doing something wrong?

Looks like there is a 'M' appended to the file path:

I:\Java\junk\M

Can you check the -filepath argument?

Paul, the "M" is part of the timestamp "Mon, 21 Sep ...".

Libin, the URL that you used is incorrect and you need to append an attachment ID at the end of the URL. The URL that you used will return a list of all attachments in XML format. The RQM URL Utility is designed in such way that whenever it sees "attachment" in a URL, it will switch to a routine to download the attachment (note that "Calling [ HTTP GET ] method to download an attachment" in the output), and expects a file name returned in the response header so that it can create such a file under the path specified in -filepath. Apparently in your case the file name was empty and the tool was trying to write a stream (the supposed attachment content) to a folder, instead of a file, hence the error.

 Thanks Donald.This is exactly what i was looking for.I am able to download the attachment without any issue.

I have uploaded a file to rqm using below command

java -jar RQMUrlUtility.jar -command PUT -user <myid> -password <mypaswd> -filepath "C:\Users\libin\Desktop\RQMxmls\out.txt" -url "https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/Demo%20(Quality%20Management)/attachment/<unique id>"

i was able to download the same attachment using below command -

java -jar RQMUrlUtility.jar -command GET -user <myid> -password <mypaswd> -filepath "I:\Java\junk\abcd.txt" -url "https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/Demo%20(Quality%20Management)/attachment/<unique id used in put command>"

Once again thanks to Donald & Paul for clarifying my doubts



One other answer

Permanent link
Yes, it's in the Content-Location response header (see https://jazz.net/wiki/bin/view/Main/RqmApi#HTTP_Responses).  However, the RQM URL Utility does not return the response headers.  You can use a PUT operation with your own external ID (see https://jazz.net/wiki/bin/view/Main/RqmApi#Create) or HTTP Requester/Poster (see https://jazz.net/wiki/bin/view/Main/RqmApi#Common_Usage_Scenarios). 

Note, https://jazz.net/wiki/bin/view/Main/RqmApi#ResourcesFootnote6.


0 votes

Comments

  I tried with PUT command also.Still i am not able to refer the attachment with user defined id.


Used the below command - 
 java -jar RQMUrlUtility.jar -command PUT -user <myid> -password <mypath> -filepath "C:\Users\libin\Desktop\abcd.txt" -url "https://localhost:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<project Area="">/attachment/<user defined="" id="">"

Can some one give more details on how to get the attachment id?

The attachment URL (-url value) should be a resource URL (see https://jazz.net/wiki/bin/view/Main/RqmApi#resourceUrl_for_interaction_with) with an ID (see https://jazz.net/wiki/bin/view/Main/RqmApi#id).  The same URL should be used in the GET request.  You can also resolve the attachment resource URL from the attachment feed (see https://jazz.net/wiki/bin/view/Main/RQMURLUtility#Command_Lines_Arguments_explaine). 

I would suggest to use HTTP Requester/Poster (see https://jazz.net/wiki/bin/view/Main/RqmApi#Common_Usage_Scenarios). 

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,948

Question asked: Sep 17 '15, 11:30 p.m.

Question was seen: 4,544 times

Last updated: Sep 22 '15, 10:56 a.m.

Confirmation Cancel Confirm