Forum Discussion

depeche's avatar
depeche
Contributor
16 years ago

How to dynamically set ContentID under Attachments using groovy or any other way

Hi,
  How can we dynamically set ContentID under Attachments using groovy script or is there any other way around?
      Scenario is something like this:

In a soap request, a text document is been attached under Attachments.

Following is the soap envelope request:



..................
....................
....................


..........................
..........................
...........................








The one, marked above in red colour is the ContentID which i am setting in the Attachments manually. Is there any way where it can be set automatically using groovy script or is there any other way around?

Thanks & regards!
depeche

1 Reply

  • Hi,

    I found the solution for the above stated problem. We can do it in groovy script by using the following piece of code

    To set the ContentID in Attachments using groovy script:

    def newContentid = "${java.util.UUID.randomUUID()}";

    testRunner.testCase.testSteps['Your Request Name'].httpRequest.getAttachmentAt(0).setContentID(newContentid);

    To get the ContentId in Attachments, use following piece of code:

    def contentId = testRunner.testCase.testSteps['Your Request Name'].httpRequest.getAttachmentAt(0).getContentID();



    regards ~ depeche