How to get the attachment id of an attachment uploaded using REST API
Accepted answer
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
Comments
Hi William,
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.
One other answer
Note, https://jazz.net/wiki/bin/view/Main/RqmApi#ResourcesFootnote6.
Comments
I tried with PUT command also.Still i am not able to refer the attachment with user defined 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).