Forum Discussion

adithyaram93's avatar
adithyaram93
New Contributor
8 months ago

Rest request attachments multipart form data for json file with parameterized json data

So I have been trying to do a scenario where i have two attachments for a rest request, one json file which i need to parameterize couple of fields from previous request. The problem with this is once you have cached the attachment you cannot modify it based on the previous test steps, So i have followed the following youtube link https://www.youtube.com/watch?v=iL-zehJmtWw

Used query parameter to use a locally store file of json to request but we are getting the error from response that application/octet-stream content type is not accepted

------=_Part_01_136051460.1696260652738
Content-Disposition: form-data; name="testFile"

testFile:/Path/to/file/testFile.json

 

I have used parameter like this testFile:${projectDir}/testFile.json

What should I do in this case

 

4 Replies

  • richie's avatar
    richie
    Community Hero

    Hi adithyaram93 

     

    Im responding to this cos no one else has - but it's been quite a while since I attached a file to a REST request in ReadyAPI! - but I do remember itgave me a headache!

     

    The error you're getting quite often occurs when the endpoint you're hitting doesn't like either the data (in the file) youre sending or it doesnt like the Content-Type header value on your request or both.

     

    I know you said you need to attach a file to a REST request and so followed the youtube vid - but have you confirmed what Content-Type header value the listening endpoint is expecting?  have you confirmed whether the header value is multipart/form-data or multipart/mixed (for attached files) or application/json for embedded files?

     

    Your listening endpoint will be expecting a specific Content-Type header value and if you send the wrong one, you'll get the sort of error response you've been seeing.

     

    Cheers,

     

    rich