Not able to hit the mock server if AllowPartialMapping is not set to true #157

Closed
opened 2025-12-29 14:23:53 +01:00 by adam · 2 comments
Owner

Originally created by @arpymastro on GitHub (Dec 14, 2018).

I am setting the mock server as below -

var server = FluentMockServer.Start(new FluentMockServerSettings
{
    Urls = new[] { "http://+/" + port },
    StartAdminInterface = true
});

Under FluentMockServerSettings if I do not set "AlowPartialMapping = true" then my request matching doesn't work. It shows - No matching mapping found.

I am stubbing my request, response as -
server

  .Given(
    Request.Create().WithPath("api/myapi").UsingGet()
  )
  .RespondWith(
    Response.Create()
      .WithStatusCode(200)
      .WithHeader("Content-Type", "application/json")
      .WithBodyAsJson(new {result= $"WireMock server is up - {DateTime.Now}"})
  );

If I set AllowpartialMapping = true then it works fine.
It is a .net core console app and I am using WireMock.Net 1.0.5 nuget package.

Originally created by @arpymastro on GitHub (Dec 14, 2018). I am setting the mock server as below - ``` c# var server = FluentMockServer.Start(new FluentMockServerSettings { Urls = new[] { "http://+/" + port }, StartAdminInterface = true }); ``` Under FluentMockServerSettings if I do not set "AlowPartialMapping = true" then my request matching doesn't work. It shows - No matching mapping found. I am stubbing my request, response as - server ``` c# .Given( Request.Create().WithPath("api/myapi").UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyAsJson(new {result= $"WireMock server is up - {DateTime.Now}"}) ); ``` If I set AllowpartialMapping = true then it works fine. It is a .net core console app and I am using WireMock.Net 1.0.5 nuget package.
adam added the question label 2025-12-29 14:23:53 +01:00
adam closed this issue 2025-12-29 14:23:53 +01:00
Author
Owner

@StefH commented on GitHub (Dec 14, 2018):

Can you:

  1. add this line to the start settings:
Logger = new WireMockConsoleLogger(),

For an example see : https://github.com/WireMock-Net/WireMock.Net/blob/master/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs#L34

This makes sure that logging is written out to console ; and there you can see what is matched or what is not matched

I think you need to add an start / to the WithPath.
Like:

server.Given(Request.Create().WithPath("/foo1").UsingGet())
@StefH commented on GitHub (Dec 14, 2018): Can you: 1. add this line to the start settings: ``` c# Logger = new WireMockConsoleLogger(), ```` For an example see : https://github.com/WireMock-Net/WireMock.Net/blob/master/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs#L34 This makes sure that logging is written out to console ; and there you can see what is matched or what is not matched 2. I think you need to add an start `/` to the WithPath. Like: ``` c# server.Given(Request.Create().WithPath("/foo1").UsingGet()) ```
Author
Owner

@arpymastro commented on GitHub (Dec 14, 2018):

@StefH - adding / at start fixed the issue.
Thank you.

@arpymastro commented on GitHub (Dec 14, 2018): @StefH - adding `/` at start fixed the issue. Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#157