WireMock.Net icon indicating copy to clipboard operation
WireMock.Net copied to clipboard

Using request multipart in response template

Open rmeshksar opened this issue 3 years ago • 7 comments

Hi, The content-type of the request is multipart/form-data; boundary=4f5cb47fa8f04c7f91424474f070f497+1110027

Each section of multipart is an XML like this:

--4f5cb47fa8f04c7f91424474f070f497+1110027
Content-Disposition: form-data; name="N1"

<xml></xml>

--4f5cb47fa8f04c7f91424474f070f497+1110027
Content-Disposition: form-data; name="N2"

<xml></xml>

--4f5cb47fa8f04c7f91424474f070f497+1110027
Content-Disposition: form-data; name="N3"

<xml></xml>

--4f5cb47fa8f04c7f91424474f070f497+1110027--

In the response template I would like to use XPath to get some information of specific section.

Is it possible?

rmeshksar avatar Jul 17 '23 15:07 rmeshksar

Currently there is no special logic to parse a multipart and extract the parts. I'll need to think on this how to could be added and how this could be used.

StefH avatar Jul 19 '23 19:07 StefH

@rmeshksar I'm building support for multipart request matching using MimeKitLite, and I think I can also use this in the templating...

StefH avatar Jul 25 '23 19:07 StefH

@rmeshksar

You can use preview version 1.5.32-ci-17678 where you can access request.BodyAsMimeMessage which is a MimeMessage from MimeKitLite.

https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

StefH avatar Jul 28 '23 12:07 StefH

@rmeshksar Did you have time to test this preview version?

StefH avatar Jul 31 '23 17:07 StefH

@rmeshksar Did you have time to test this preview version?

It would really help if you can try this version before I merge to this main and create a new official version.

StefH avatar Aug 03 '23 11:08 StefH

https://github.com/WireMock-Net/WireMock.Net/pull/981

StefH avatar Aug 03 '23 13:08 StefH

Hi @StefH, would this PR solve my problem here: https://stackoverflow.com/questions/77989392/wiremock-net-c-how-to-get-a-pdf-from-a-request-body-form-data

Also is part of the latest nuget package 1.5.47?

eetawil avatar Feb 13 '24 21:02 eetawil