Using request multipart in response template #526

Closed
opened 2025-12-29 15:25:56 +01:00 by adam · 7 comments
Owner

Originally created by @rmeshksar on GitHub (Jul 17, 2023).

Originally assigned to: @StefH on GitHub.

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?

Originally created by @rmeshksar on GitHub (Jul 17, 2023). Originally assigned to: @StefH on GitHub. 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?
adam added the feature label 2025-12-29 15:25:56 +01:00
adam closed this issue 2025-12-29 15:25:56 +01:00
Author
Owner

@StefH commented on GitHub (Jul 19, 2023):

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 commented on GitHub (Jul 19, 2023): 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.
Author
Owner

@StefH commented on GitHub (Jul 25, 2023):

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

@StefH commented on GitHub (Jul 25, 2023): @rmeshksar I'm building support for multipart request matching using MimeKitLite, and I think I can also use this in the templating...
Author
Owner

@StefH commented on GitHub (Jul 28, 2023):

@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 commented on GitHub (Jul 28, 2023): @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
Author
Owner

@StefH commented on GitHub (Jul 31, 2023):

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

@StefH commented on GitHub (Jul 31, 2023): @rmeshksar Did you have time to test this preview version?
Author
Owner

@StefH commented on GitHub (Aug 3, 2023):

@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 commented on GitHub (Aug 3, 2023): @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.
Author
Owner

@StefH commented on GitHub (Aug 3, 2023):

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

@StefH commented on GitHub (Aug 3, 2023): https://github.com/WireMock-Net/WireMock.Net/pull/981
Author
Owner

@eetawil commented on GitHub (Feb 13, 2024):

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 commented on GitHub (Feb 13, 2024): 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?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#526