mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Is there a way to store a HTTP Request Body as a file? #403
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 @Loydik on GitHub (Feb 10, 2022).
Hi,
I am wondering how to store HTTP request body as a file using wiremock.net, and cannot figure it out. I have a service which uses another service to upload a file to Azure Datalake, lets call it FileUploader. It receives file contents in HTTP request body, and then it uploads it to Datalake. I would like to mock FileUploader, and instead of sending stuff to Datalake, the mock should take http request body and store it, so I can access it later (store it as a file, or any other solution really).
There is a good article on how to achieve this in java Wiremock using Extensions, but it seems not to be possible in Wiremock.Net for some reason. Was extending Wiremock not implemented in .Net version? Or am I missing something? Here is an article:
https://medium.com/edc-dev-chapter/storing-a-http-request-body-using-a-wiremock-extension-ef3f2a60abcb
Thank you very much!
@StefH commented on GitHub (Feb 11, 2022):
@Loydik
A possible solution would be to run WireMock.Net in proxy mode https://github.com/WireMock-Net/WireMock.Net/wiki/Proxying
Another option would be to view the requests which are made to WireMock:
https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Server/WireMockServer.LogEntries.cs#L40
Notice that WireMock.Net is internally not the same as WireMock
@Loydik commented on GitHub (Feb 14, 2022):
@StefH thank you, that was helpful :)