mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Wiremock.net (C#) how to get a PDF from a Request body (form-data ) #575
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @eetawil on GitHub (Feb 14, 2024).
I tired on SO: https://stackoverflow.com/questions/77989392/wiremock-net-c-how-to-get-a-pdf-from-a-request-body-form-data
I'm also posting it here to get better reach...
=>
We are using wiremock.net (C#) and we want to extract from the request the PDF file contained in that Request. How can we do that? I'm new to wiremock and I read about response templating without success.
Can someone please help with either documentation or code sample for this?
In other words how to GET_PDF FILE_HERE_FROM_REQUEST (see code below)
@StefH commented on GitHub (Feb 14, 2024):
In your example you are posting a form which has 2 fields: a file field, which contains the PDF and a json text field.
If you want to return a JSON response, you need to use the method (which gives you the request object and should return an anonymous object which will be serialized to JSON:
And the
IRequestMessagecontains a propertyBodyAsMimeMessagewhich is anMimeKit.MimeMessageobject which contains several body parts which you can get and use if needed.Example:
See https://github.com/jstedfast/MimeKit for more details
@eetawil commented on GitHub (Feb 14, 2024):
Thank you very much for your input and directions!