v1.5.33 Returns always StatusCode 500 #538

Closed
opened 2025-12-29 08:29:41 +01:00 by adam · 2 comments
Owner

Originally created by @macalbert on GitHub (Aug 4, 2023).

Originally assigned to: @StefH on GitHub.

Describe the bug

Version 1.5.33 always returns StatusCode 500 ' Internal Server Error'.

Expected behaviour:

Should return the StatusCode provided in the ResponseBuilder.

Test to reproduce

using System.Net;
using System.Text;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;

public class SomeApiClientTests
{
    [Fact]
    public async Task Should_ReturnCreated_When_PostRequestedIsValid()
    {
        // Arrange        
        var server = WireMockServer.Start();
        server.Given(Request.Create().UsingPost().WithPath("/some/endpoint"))
              .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.Created));
        var httpClient = new HttpClient { BaseAddress = new Uri(server.Url!) };
        var requestUri = new Uri(httpClient.BaseAddress!, "some/endpoint");
        var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");

        // Act
        var actual = await httpClient.PostAsync(requestUri, content);

        // Assert
        actual.StatusCode.Should().Be(HttpStatusCode.Created);
    }
}

Ran under .Net 7 with Microsoft Visual Studio Community 2022 (64-bit) -Version 17.6.5

Originally created by @macalbert on GitHub (Aug 4, 2023). Originally assigned to: @StefH on GitHub. ### Describe the bug Version 1.5.33 always returns StatusCode 500 ' Internal Server Error'. ### Expected behaviour: Should return the StatusCode provided in the ResponseBuilder. ### Test to reproduce ```csharp using System.Net; using System.Text; using WireMock.RequestBuilders; using WireMock.ResponseBuilders; using WireMock.Server; public class SomeApiClientTests { [Fact] public async Task Should_ReturnCreated_When_PostRequestedIsValid() { // Arrange var server = WireMockServer.Start(); server.Given(Request.Create().UsingPost().WithPath("/some/endpoint")) .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.Created)); var httpClient = new HttpClient { BaseAddress = new Uri(server.Url!) }; var requestUri = new Uri(httpClient.BaseAddress!, "some/endpoint"); var content = new StringContent(string.Empty, Encoding.UTF8, "application/json"); // Act var actual = await httpClient.PostAsync(requestUri, content); // Assert actual.StatusCode.Should().Be(HttpStatusCode.Created); } } ``` ### Other related info Ran under .Net 7 with Microsoft Visual Studio Community 2022 (64-bit) -Version 17.6.5
adam added the bug label 2025-12-29 08:29:41 +01:00
adam closed this issue 2025-12-29 08:29:42 +01:00
Author
Owner

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

Hello @macalbert.
Thanks for reporting.

I will release a new version soon.

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

@StefH commented on GitHub (Aug 4, 2023): Hello @macalbert. Thanks for reporting. I will release a new version soon. https://github.com/WireMock-Net/WireMock.Net/pull/989
Author
Owner

@macalbert commented on GitHub (Aug 4, 2023):

Thanks @StefH!! 😃

@macalbert commented on GitHub (Aug 4, 2023): Thanks @StefH!! :smiley: <img src="https://media1.giphy.com/media/3ov9jI268BAjY0MGaI/giphy.gif"/>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#538