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

Uploading an attachment to RQM: success reported but no attachment or no id

 I have been trying unsuccessfully to perform this seemingly simple task:
(1) Upload the attachment to RQM 
(2) Have the link to it displayed in Test Case result area.

If I use the existing attachment that was uploaded by Command Line adapter, (2) works fine. So, all I need to be able to do is either (a) upload the attachment with POST and get the generated id; or (b) upload with PUT and tell it what ID I want to use, and what "title" I want to associate with it. Neither was successful. POST returns 200 (OK), and no headers or body with the ID. PUT reports 201 (created), but subsequent GET with the same URL returns 404 (Not found). I suspect that in no case an attachment was actually created on the server.

I know about the footnote 6 in the spec that Paul Slauenwhite is always referencing and I did my best to follow all of those guidelines, but nothing helped.

I also enabled traces for the adapter and I tried to repeat what it is doing, but unsuccessfully. One complication is that I am using the newer HTTP client from the HTTP Components, so I cannot exactly repeat what the adapter is doing. 

However, HttpRequester should be good enough to execute any of those requests.  I had no success with that either: same story - success reported, but id is not returned or the file is not found.

My question is this: can somebody please show me a working example in HttpRequester of how to achieve this thing: upload an attachment and have its id known, one way or another?

We are using RQM 5.0.2.

0 votes



2 answers

Permanent link
I think you left something critical out in your original post - what tool are you using? From what you described, it appears that you are using RQM URL Utility - is it true? You made it even confusing with the mention of Command Line Adapter and HTTP client.

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)
            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()));
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.

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()));

0 votes

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:

(1) I am writing my own RQM client, in java. As part of its functionality, it needs to upload an attachment and get its id ("the "slug" should work for me, too).
(2) I am studying the source of all the sample apps, including URL Utility.
(3) I am also studying the behavior and the log4j traces of Command Line Adapter, where it performs the same attachment upload. 
(4) I am using apache HttpClient 4.5.1 (from the newer HttpComponents project). This library is the replacement of HttpClient 3.x, which has been retired. The two are quite different. I did not want to use the retired library, even though all samples and the "production" code for Command Line Adapter do in fact use the older library.
(5) To cut all those details from the consideration, I wanted to ask the question using the commonly-used tool HttpRequester, which is a Firefox plugin, and which is recommended by the RQM doc.
(6) This HttpRequester behaves the same way as my utility: it says that the request is successful, but does not return the id - neither in the header, nor in the body. This is no surprise, of course, because I am filling in the same headers, etc. the same way in my utility and in HttpRequester.
(7) I was hoping that somebody would show me an example of how to upload something as an attachment and get its id - in HttpRequester. Pasting the details of the communication as shown by HttpRequester (includes all headers and the body of both response and request) into this post would help me tremendously. (Of course, make sure to mask any sensitive info, like the session cookie, if you believe that it can compromise your system.)

 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...


There is some difference, though: when I do GET on the returned URL (eg, paste it in the browser), the URL I get from URL Utility does give me the file; but the URL I get from HttpRequester produces 404 (Not Found), even though I got 201 when I created it. Have not been able to crack that one yet...

Another curious thing is the attachment feed. Nothing that I add - or the Command Line Adapter adds - is shown in that feed. So, when I GET
.../service/com.ibm.rqm.integration.service.IIntegrationService/resources/<project-alias>/attachment/

I see some nicely formatted list but with very old files, whose names look like they came as samples during installation. Kind of like a seeing a default "Hello World" page in a new installation of a web server. I know for sure that some attachments do exist, and show up in the test case results, but they are not given in that list. In fact, I just created one with URL Utility and I am able to get its contents back. Any idea what can be happening there?

Also, do you know what is the deal with posting to /secure/service/com.ibm.rqm.planning.service.internal.rest.IAttachmentRestService?

This is what the log from running Command Line Adapter shows. They post an attachment to that URL with two parameters:
"?customField=SomeJunkFile&projectAlias=<project-alias>"

The test case result attachment created by Command Line Adapter also uses the link with IAttachmentRestService and the "slug" kind of ID.

The jazz docs and the URL Utility actually want you to post to  /service/com.ibm.rqm.integration.service.IIntegrationService/resources/<project-alias>/attachment/

Now that I am at least getting the slug id, I was hoping to experiment more today with RQM, but unfortunately our RQM server has been down most of the day... I'll try to post updates after the server comes up. In the meantime, if you can shed the light on what I wrote above, that would be very helpful. 

Thanks again. I appreciate your help.

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
These seem to be exactly the symptoms that you've described, that's why I haven't started a new question.

Do you have any updates since then? (How) did you manage to solve this?
Anyone else with updates (or success stories) on this issue?


Permanent link
 I am using resteasy client api for calling web services. I am not able to upload attachment to rqm. Can you please help me with your client code

0 votes

Comments

You should consider open a new post and state clearly in details what your issue is. Or do you just want to copy the code from others?

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
× 8

Question asked: Dec 16 '15, 5:36 p.m.

Question was seen: 2,670 times

Last updated: Sep 19 '18, 6:32 a.m.

Confirmation Cancel Confirm