Solved! Go to Solution.
Hi everyone,
I had a discussion with customer support regarding this issue, and they suggest the solution.
To specify your content type and remove name of the file after it, you should add event handler to the request. Steps are the next:
1) Click on your project through the navigator then click on the "Events" button on the top right of the application (underneath the LoadUI tab)
2) Click the green plus button to add a new event and then select the "RequestFilter.filterRequest" Event Handler
3) Click on the RequestFilter (if it's not selected already) and copy+paste the below script into the box below:
def bodyPart = context.getProperty("httpMethod").requestEntity.message.content.getBodyPart(0) // get a part by number, it starts with 0 bodyPart.removeHeader("Content-Type") bodyPart.addHeader("Content-Type", "application/content-type+xml") // specify the value without the name parameter
The above script completely removes the Content-Type Header from the raw request and replaces it with only the desired content type (so in this case, application/content-type+xml).
4) Afterwards, please run your request with the attachment (and with no parameters).
Please pay attantion that this part
.getBodyPart(0)
is used because I'm working with xml attachments, so for other content types script may differ.
This solution resolved my problem, so I hope it will help you
Hi Support,
Is this bug resolved that adds name feild with Content-Type in attachment ?
I have tried this solution by adding parameter value to "file:filename" ,but in this way it is taking wrong content-type for that attachment ,In my case I am attaching a JSON file but it is showing wrong Content-Type text/javascript which should be application/json. it looks like again a issue. there is no option to change Content-Type of attach file part request for multipart.
Please suggest if is there any way arround
Thanks
Abhishek
Hi,
Is this bug resolved?
I've tried the suggested solutions,but sadly, they didn't work, my content-type is still being overwritten. Without the solution for this problem I can't continue with my work. If there's any other solution for this problem, I would by thankful for the tip.
Thanks,
Magda
sorry for double posting
Hi everyone,
I had a discussion with customer support regarding this issue, and they suggest the solution.
To specify your content type and remove name of the file after it, you should add event handler to the request. Steps are the next:
1) Click on your project through the navigator then click on the "Events" button on the top right of the application (underneath the LoadUI tab)
2) Click the green plus button to add a new event and then select the "RequestFilter.filterRequest" Event Handler
3) Click on the RequestFilter (if it's not selected already) and copy+paste the below script into the box below:
def bodyPart = context.getProperty("httpMethod").requestEntity.message.content.getBodyPart(0) // get a part by number, it starts with 0 bodyPart.removeHeader("Content-Type") bodyPart.addHeader("Content-Type", "application/content-type+xml") // specify the value without the name parameter
The above script completely removes the Content-Type Header from the raw request and replaces it with only the desired content type (so in this case, application/content-type+xml).
4) Afterwards, please run your request with the attachment (and with no parameters).
Please pay attantion that this part
.getBodyPart(0)
is used because I'm working with xml attachments, so for other content types script may differ.
This solution resolved my problem, so I hope it will help you
Hi @anastasiia,
Thanks for sharing the solution with us. I've marked it accordingly!
Subject | Author | Latest Post |
---|---|---|