how to change HTTP multipart headers
Hello, I don't found any way, how to set correct content-type of my file inside of multipart/form-data media.
* When I rewrite the type in attachement table, the value is not used in REST call.
* when I put my JSON directly to body as an text, then again no way, how to set my correct content type to "application/json".
My target is to use JSON in body, have it full of properties, and then one binary file in attachement. But how to do that?
this is often mentioned problem in forums. In SoapUI PRO, there is a way, how to use events and simple script. It works even in free version. Only one problem here. When I put the script directly to the code (to the body of request), it's produce error message = in RAW request is visible some text, and server parser dont knwo, what this is. Next time, this error dissapier.
So my question is, how to avoid this error.
Script in body:
// get a part by number, it starts with 0
def bodyPart = context.getProperty( "httpMethod" ).requestEntity.message.content.getBodyPart( 0 )
bodyPart.removeHeader( "Content-Type" );
// specify the value without the name parameter
bodyPart.addHeader( "Content-Type" , "application/json" );
bodyPart.addHeader( "Content-Disposition" , "form-data; name='json'" );
Thank you very much for your advice in advance.
PS: support team haves no idea, how to set objects before request is send. NULL pointer is visible, thanks to requestEntity.message is not exists yet. My idea is (because script works), to initialize this first.. then use this script.