Forum Discussion

mbarua's avatar
mbarua
New Contributor
7 years ago

how to remove boundary part from raw request

In my case I need to attach a file through Ready API. When i am attaching and sending the request ready api automatically add some extra header and footer. I was able to remove some of it but still i am unable to delete boundary value which is auto generated and it is automatically adding to my raw request and when i am retrieving the file i am getting that boundary value back within my attachment. Please can you share your experience to resolve that issue.

i used the below code to remove extra header and footer:::

ef bodyPartAttach = context.getProperty("httpMethod").requestEntity.message.content.getBodyPart(0) // get a part by number, it starts with 0

bodyPartAttach.removeHeader("Content-Transfer-Encoding")

 

But i need to remove the  "------ part= . '' from header and footer. I attached an image here. This part is going to add within my file whatever it is. if it is text file, pdf or any kind of file.

3 Replies

    • mbarua's avatar
      mbarua
      New Contributor

      Thank you Nastya.

      How to apply the below . I did not get chunking threshold under preferences.

      File -> Preferences -> Сhunking threshold 

       

      And applying the below code the file did not attach even and did not go to server storage

      import org.apache.http.entity.FileEntity
       
      FileEntity fe = new FileEntity(new File("C:\\temp.xls"),"application/octet-stream") // specify the file location
      //fe.setChunked(true) // to send a file in chunks
      context.getProperty("httpMethod").setEntity(fe)

       

      Please help.

      • Nastya_Khovrina's avatar
        Nastya_Khovrina
        SmartBear Alumni (Retired)

        Hi Mous,

         

        Can you provide me with an expected raw request and the request which you get in ReadyAPI?