mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
How to send a request to a specific URL after sending response #338
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 @samiransaha on GitHub (Mar 3, 2021).
The java version of wiremock supports Post-serve actions mentioned here http://wiremock.org/docs/extending-wiremock/.
By using this we can send request to a specific URL after serving mocked response to a request. Is it possible to with wiremock.net? if yes, can we configure it via JSON and does it support authentication?
@StefH commented on GitHub (Mar 3, 2021):
You are looking for a hook / callback which will be triggered after the response has been returned?
@samiransaha commented on GitHub (Mar 4, 2021):
Yes. Hook/Callback would be generic. So, that we can do something like this https://blog.jdriven.com/2020/10/using-wiremock-in-an-async-environment/
But in addition, if we can have some predefined post-serve hook like sending request to URL and surface it via JSON configuration, so that one can configure it via JSON mapping files then it would be great. Although I am not sure is it possible to inject stub code here in json config file or not because most people will need some mechanism to get actual token and send in Auth header.
Something like below:
@StefH commented on GitHub (Mar 5, 2021):
Dear @samiransaha, I did update your question with some code formatting so that it it's better readable.
I think this can be implemented, however it will take some effort.
And maybe instead of letting the user define the content, it's maybe easier to just forward the complete request and response to that callback hook. So that all data is present.
@samiransaha commented on GitHub (Mar 6, 2021):
Thanks @StefH.
Glad to know.
I think there should be an option to send custom request body while sending request in hook along with the option to send complete request body received the way have mentioned.
@StefH commented on GitHub (Mar 8, 2021):
@samiransaha
I've created a preview nuget on myget:, can you please test vesion WireMock.Net.1.4.7-ci-14761 ?
-- >https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
Only Body or BodyAsJson is supported. No transformation (yet)
example
@StefH commented on GitHub (Mar 9, 2021):
@samiransaha A new version
WireMock.1.4.7-ci-14768should now also support transformation.Add
"UseTransformer": true@samiransaha commented on GitHub (Mar 10, 2021):
Thanks @StefH, I will check it.
Another thing not related to webhook, I wanted to know is it possible to configure delay before sending response via JSON or not sending any response entirely?
Something like this in java version of wiremock http://wiremock.org/docs/simulating-faults/
@samiransaha commented on GitHub (Mar 10, 2021):
I am using the wiremock as dotnet tool. How to get your CI version for that?
@StefH commented on GitHub (Mar 10, 2021):
See https://github.com/WireMock-Net/WireMock.Net/wiki/Faults
@StefH commented on GitHub (Mar 10, 2021):
it's on the same MyGet feed:
https://www.myget.org/feed/wiremock-net/package/nuget/dotnet-WireMock
@samiransaha commented on GitHub (Mar 10, 2021):
Can we add Faults like no response at all? Correct me if I am wrong with the exiting Faults I will not be able to add delay before response or completely no response, to simulate server is down. Both are good candidate for fault for integration tests.
Thanks @StefH, sorry I missed that in myget link.
@StefH commented on GitHub (Mar 12, 2021):
@samiransaha Did you have time to test it ?
@StefH commented on GitHub (Mar 17, 2021):
@samiransaha Did you have to test?
@StefH commented on GitHub (Mar 23, 2021):
@samiransaha Can you please test this?
@samiransaha commented on GitHub (Mar 23, 2021):
@StefH , Hey sorry for delay, I got sick, and was not able to catch up my emails. I will test this today, and let you know.
@samiransaha commented on GitHub (Mar 23, 2021):
Hi @StefH,
I used following rule it didn't work for me looks like.
I got the response, but the webhook request generation failed.
And I see following error is console. Any Idea?
@StefH commented on GitHub (Mar 23, 2021):
Very strange, according to WIKI it looks fine. (https://github.com/WireMock-Net/WireMock.Net/wiki/Webhook)
See also this unit tests (
819629125c/test/WireMock.Net.Tests/WireMockServer.WebhookTests.cs)Did you try another address?
@samiransaha commented on GitHub (Mar 24, 2021):
Hey it worked now, there was network issue with that port for that time being.
@StefH commented on GitHub (Mar 24, 2021):
@samiransaha Thanks for testing.
I'll merge the PR and create a new official NuGet version today or at most tomorrow.