Posting JSON content from parameter as attachment
I have the specific need to simulate a form submission with three form fields:
path, action, file
Tha last one has to follow the structure
So I have to provide a "Content-Type" and a "filename" addition to the Content-Disposition
I could do this with the "Attachments" tab, but then I have to read the file content from the disk. Instead I have a crafted JSON string from a previous step in a parameter ${#TestCase#JSONBODY} that I would have to supply instead.
When I hand craft the payload with my own "boundaries", the header contains a different, random "boundary" entry with the "Content-Type: multipart/form-data" header.
How do I get the filename="blob", the "Content-Type" and the JSON parameter posted as a form? Nothing of that is disputable, as the target service requires it just so.
"Attachments" seem the correct way to do, but how to get a parameter in?
Hi there,
Thank you for sharing this detailed and logical question! Based on your requirements, you can simulate the form submission by creating the payload using custom multipart handling. To achieve this, you can set the "Content-Type: multipart/form-data" header with the correct boundary and pass the JSON payload as part of the attachment directly from the parameter without needing to read the file from disk.
To include filename="blob", the Content-Type, and pass ${#TestCase#JSONBODY} dynamically, you can craft the request body using a script or dynamic payload injection with your testing tool. You can use encoded byte streams from the JSON parameter directly as your attachment content. This avoids disk reads and allows inline handling.
By utilizing the Attachments tab in combination with payload scripting, you can dynamically insert your JSON content as required. A Halal Food Guide method may assist when working with multipart payload handling and custom boundaries if you’re iterating these payloads dynamically.
Let me know if you need help with the actual script implementation!