Forum Discussion

g_eijlders's avatar
g_eijlders
New Contributor
10 years ago

Content-Disposition paramters

How can I add custom parameters in the Content-Disposition of a multipart/form-data request?



See example below want I want to achieve:



------=_Part_20_13894859.1421339164343

Content-Type: application/pdf; name=tekening1.pdf

Content-Transfer-Encoding: binary

Content-Disposition: form-data; name="tekening1.pdf"; filename="tekening1.pdf";custompar="test"



3 Replies

  • Hi,

     

    Use the following Groovy script in the event handler RequestFilter.filterRequest:

     

    def count = context.getProperty("httpMethod").requestEntity.message.content.count
    for (def i=0; i < count; i++)
    {
    def bodyPart = context.getProperty("httpMethod").requestEntity.message.content.getBodyPart(i)
    bodyPart.disposition = bodyPart.disposition + " ;custompar=\"test\""
    }

     

    That will add the custom pararmater to the content dispostion.  Link below gives more information on custom event handlers in Ready API.

     

     

    http://readyapi.smartbear.com/loadui/scripts/intro/event_handlers

     

    Regards,

    Marcus

    SmartBear Support

    • doogra's avatar
      doogra
      Occasional Visitor

      I also have a problem where I need to add a parameter called "uploadFile" to the Content-Disposition parameters per the below example:

       

      Content-Disposition: form-data; name="uploadFile"; filename="bar-12.0.2.30.bar"

       

      However, I do not understand the example solution you provided. It appears to apply only to LoadUI. Can you please provide detailed steps on how to accomplish this using SoapUI Pro? I'm using verison 5.1.2. Thanks!

       

      Update:

      Never mind....I figured it out. Needed to manually change the contentId value in the attachments tab so that it read "uploadFile".