Forum Discussion

richie's avatar
richie
Community Hero
6 years ago

Submitting a multipart/form-data request generates automatic boundary - but only on start and finish

Hi,

 

Bit embaressed I can't sort this out cos its functionality not coding - but I'm struggling - I need to use the multipart/form-data type in a request (no other will do apparently - even though its just some text I'm sending to the server) and ReadyAPI!'s generation of the automatic boundary is causing me some real problems and I'm not the only one considering all the posts I've found on this - occasionally people have found ways around it, but the fixes cant help me as far as I could see.

This is another example where it works fine in Postman but when I try with SoapUI I have problems - I'm not saying it works correctly in Postman cos I dont actually think it does in this case, but I'm struggling with ReadyAPI!

 

Essentially I have a multiattribute payload that I MUST use the multipart/form-data type - but the automatic boundaries are ONLY generated at the header and footer of the request.  

 

My payload has the following name/value pair requirements:

grant_type:password
client_id:e621ab05-3417-4482-a1e4-de86705bfcb7
client_secret:a%2BOPsfWybHR8VBvLIbzBZCHjWhzAAbUHahJNFNWcOho%3D
resource:e621ab05-3417-4482-a1e4-de86705bfcb7
username:exportsadministrator@defrasandpit.onmicrosoft.com
password:Rojo5166!

I populate the Request form (below the mediatype dropdown) with the detail below (excepting the automatically generated boundaries wrapping the content

 

------=_Part_22_4377865.1561564369180 (AUTO GENERATED BOUNDARY)

Content-Disposition: form-data; name="grant_type" password Content-Disposition: form-data; name="client_id" e621ab05-3417-4482-a1e4-de86705bfcb7 Content-Disposition: form-data; name="client_secret" a+OPsfWybHR8VBvLIbzBZCHjWhzAAbUHahJNFNWcOho= Content-Disposition: form-data; name="resource" e621ab05-3417-4482-a1e4-de86705bfcb7 Content-Disposition: form-data; name="username" exportsadministrator@defrasandpit.onmicrosoft.com Content-Disposition: form-data; name="password" Rojo5166! ------=_Part_22_4377865.1561564369180-- (AUTO GENERATED BOUNDARY)

HOWEVER - the above fails which I'm guessing because I need boundaries BETWEEN the attributes as well as having a header/trailer boundary - so the content that works (scraped via Postman) looks as follows:

 

----------------------------819072124639882311836182
Content-Disposition: form-data; name="grant_type"

password
----------------------------819072124639882311836182
Content-Disposition: form-data; name="client_id"

e621ab05-3417-4482-a1e4-de86705bfcb7
----------------------------819072124639882311836182
Content-Disposition: form-data; name="client_secret"

a+OPsfWybHR8VBvLIbzBZCHjWhzAAbUHahJNFNWcOho=
----------------------------819072124639882311836182
Content-Disposition: form-data; name="resource"

e621ab05-3417-4482-a1e4-de86705bfcb7
----------------------------819072124639882311836182
Content-Disposition: form-data; name="username"

exportsadministrator@defrasandpit.onmicrosoft.com
----------------------------819072124639882311836182
Content-Disposition: form-data; name="password"

Rojo5166!
----------------------------819072124639882311836182--

 

Does anyone know how edit the content (or the properties of the request) to get the boundaries to appear BETWEEN the attributes as well as wrapping them? - I've tried manually adding the Content-Type : multipart/form-data; boundary=" header and played around with this - but I just can't see a way for the boundaries to generate BETWEEN the attributes.

 

 

There was a person that found a way around this via this link (by manually specifying the boundaries by specifying the boundary as a custom header (e.g. multipart/form-data; boundary="----WebKitFormBoundary7MA4YWxkTrZu0gw) as well as ensuring the boundary value wrapped the payload and was between the attributes - HOWEVER - that was a couple of years ago and it looks like there's been some coding since cos when I specify the boundary as in the link, ReadyAPI! still inserts the automatically generated header and footer boundaries - so my request is invalid.

 

I'm thinking I've found another defect for Radford's list! :)

 

I'd welcome any help at all at this point - I've been playing with this for the last 4 hours with no luck!

 

cheers,

 

rich

  • Nastya_Khovrina's avatar
    Nastya_Khovrina
    SmartBear Alumni (Retired)

    Hi richie 

     

    You can do the following:

    1. Specify your properties as query parameters of a request.

    2. Check the Post QueryString option.

    3. Don't forget to clear the Request form (below the Media Type dropdown)

    Please see the screenshot:

     

    Here is what you'll get as a result:

     

     

    Also, here are some useful resources:

    LearnUpon: https://smartbearacademy.learnupon.com/enrollments/25031374

    YouTube: https://www.youtube.com/watch?v=iL-zehJmtWw&list=PLrA5ciulugn_w0pW1_SSyfucD-k5Fasj_&index=5

    • richie's avatar
      richie
      Community Hero

      Hey Nastya_Khovrina 

       

      Thankyou!

       

      But I think I've found another defect which now I can see was causing me a lot of the problems - I kept thinking I was doing something wrong because whenever I went from Projects to SoapUI to add the request into the testcase - the parms were blank.

       

      That is -  I can create the request in the Projects section adding the payload in as query parms - and submit the request using the type and query parms as you suggest within the Projects tab only and the request is successful.

       

      HOWEVER - when I go into the SoapUI tab - and add the new request to the testcase the parameters are BLANK - i.e. they're not present - and I can't alter the parms on a request in the SoapUI tab - if I go back into the Projects tab - I can see my request with the queryparms as created before.

       

      Nastya_Khovrina can you please try and replicate this? - it's quite a hindrance if you can't actually use the request within a testcase when the type is 'multipart/form-data'!

       

      Thank you for all your help! :)

       

      rich

       

       

      • Nastya_Khovrina's avatar
        Nastya_Khovrina
        SmartBear Alumni (Retired)

        Hi rich,

         

        Yes, I can reproduce this behavior, but, this is by design. When working with tests, you may want to specify different parameter values.