Uploading an attachment to RQM: success reported but no attachment or no id
2 answers
If that's the case, you are most likely seeing the same issue as in this post.
https://jazz.net/forum/questions/179547/upload-attachment-to-a-test-artifact-with-rqm-url-utility-rest-api
Note that with the RQM URL Utility, it's meant to be a sample only and you should study the source code and make it work in the way you like.
For example, with the POST method, you and add the following code to the file RQMUrlUtility/src/com/ibm/rqm/url/client/RQMUrlPOST.java to show the URL of the new artifact.
if (responseCode == 201)Note: It's interesting to note that the returned URL has a "slug" Id for an attachment, but in the attachment feed, the resource actually has a proper urn:com.ibm.rqm.attachment:## ID.
System.out.println("RQMUrlUtility: [ New Resource URL ] " + method.getResponseHeader("Location"));
if (responseCode < 400)
System.out.println("RQMUrlUtility: [ SUCCESS ] File : \"" + sPath
+ "\" successfully posted to URL : \"" + sAttachURL + " \"");
else
System.out.println("RQMUrlUtility: [ ERROR ] " + new String(method.getResponseBody()));
For the PUT method, the ReadMe file or online help is a bit misleading, as the "-filepath" should point to an XML file containing of the payload of the PUT operation, not an "attachment". You can also add the following code to RQMUrlUtility/src/com/ibm/rqm/url/client/RQMUrlPUT.java to show you why the PUT operation fails.
if (responseCode < 400)
System.out
.println("RQMUrlUtility: [ SUCCESS ] XML string from file : \""
+ sPath
+ "\" written to URL : \""
+ sAttachURL
+ " \"");
else
System.out.println("RQMUrlUtility: [ ERROR ] " + new String (put.getResponseBody()));
Comments
Donald, thank you for your answer. I left out the low-level details in order to help prevent confusion, but apparently it had the opposite effect. Here is the deal:
Donald, please see my answer below. It was too long for a comment. Since I was not able to add my response as a comment, I just added it as another answer...
To accommodate a long comment, you can post it as an "answer" first, and then convert it to a comment (using the "More" menu).
So what you're saying is that even with HTTP 201 code, you cannot see the URL in the response header "Location"?
At the very least, if you get the feed of attachments (the list of all attachments of a project area), can you see the new attachment? That's the less desirable way to get the URL but it should still work.
Actually, I am starting to get the slug in the header Location when I run both URL Utility and HttpRequester; I was not getting that header yesterday in the HttpRequester. I am pretty sure I was missing something in the request...
Mikhail, almost 3 years since your posting, and now I'm stuck here with exactly the same issue and questions (only difference is that we do use C# instead of Java for our custom RQM client and we now have RQM 6.0.5):
- PUT-request on /service/com.ibm.rqm.integration.service.IIntegrationService/resources/<project-alias>/attachment returns "201 Created" with empty body
- The attachment does not seem to have been uploaded after the PUT-request
- GET-request on attachment-node returns a list of old attachments, but does not include new attachments
Anyone else with updates (or success stories) on this issue?