422 Unprocessable Entity #569

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

Originally created by @chertby on GitHub (Jan 28, 2024).

I run a WireMock in docker and then use WireMock.Net.RestClient to create the mappings.

mappingBuilder.Given(m => m
    .WithTitle("This is my title 1")
    .WithRequest(req => req
        .UsingGet()
        .WithPath("/bla1")
    )
    .WithResponse(rsp => rsp
        .WithBody("x1")
        .WithHeaders(h => h.Add("h1", "v1"))
        .WithStatusCode(StatusCodes.Status200OK)
    )
);

await mappingBuilder.BuildAndPostAsync(cancellationToken);

I get an error:

{
  "errors" : [ {
    "code" : 10,
    "source" : {
      "pointer" : "/"
    },
    "title" : "Error parsing JSON",
    "detail" : "Cannot deserialize value of type `com.github.tomakehurst.wiremock.stubbing.StubMapping` from Array value (token `JsonToken.START_ARRAY`)"
  } ]
}

The client allows to send a collection of mappings

/// <summary>
/// Add new mappings.
/// </summary>
/// <param name="mappings">MappingModels</param>
/// <param name="cancellationToken">The optional cancellationToken.</param>
[Post("mappings")]
[Header("Content-Type", "application/json")]
Task<StatusModel> PostMappingsAsync([Body] IList<MappingModel> mappings, CancellationToken cancellationToken = default);

But if believe the specification, then there is no such endpoint.

I can't figure it out, am I doing something wrong?

Originally created by @chertby on GitHub (Jan 28, 2024). I run a WireMock in docker and then use `WireMock.Net.RestClient` to create the mappings. ```csharp mappingBuilder.Given(m => m .WithTitle("This is my title 1") .WithRequest(req => req .UsingGet() .WithPath("/bla1") ) .WithResponse(rsp => rsp .WithBody("x1") .WithHeaders(h => h.Add("h1", "v1")) .WithStatusCode(StatusCodes.Status200OK) ) ); await mappingBuilder.BuildAndPostAsync(cancellationToken); ``` I get an error: ```json { "errors" : [ { "code" : 10, "source" : { "pointer" : "/" }, "title" : "Error parsing JSON", "detail" : "Cannot deserialize value of type `com.github.tomakehurst.wiremock.stubbing.StubMapping` from Array value (token `JsonToken.START_ARRAY`)" } ] } ``` The client allows to send a collection of mappings ```csharp /// <summary> /// Add new mappings. /// </summary> /// <param name="mappings">MappingModels</param> /// <param name="cancellationToken">The optional cancellationToken.</param> [Post("mappings")] [Header("Content-Type", "application/json")] Task<StatusModel> PostMappingsAsync([Body] IList<MappingModel> mappings, CancellationToken cancellationToken = default); ``` But if believe the [specification](https://wiremock.org/docs/standalone/admin-api-reference/#tag/Stub-Mappings/paths/~1__admin~1mappings/post), then there is no such endpoint. I can't figure it out, am I doing something wrong?
adam added the question label 2025-12-29 08:30:20 +01:00
adam closed this issue 2025-12-29 08:30:20 +01:00
Author
Owner

@chertby commented on GitHub (Jan 28, 2024):

Oh, it was my mistake I used the basic image wiremock/wiremock instead of sheyenrath/wiremock.net.

@chertby commented on GitHub (Jan 28, 2024): Oh, it was my mistake I used the basic image `wiremock/wiremock` instead of `sheyenrath/wiremock.net`.
Author
Owner

@StefH commented on GitHub (Jan 28, 2024):

Correct.

If you want to use a RestClient to access the WireMock Java version, you can try WireMock.Org.RestClient.

@StefH commented on GitHub (Jan 28, 2024): Correct. If you want to use a RestClient to access the WireMock Java version, you can try `WireMock.Org.RestClient`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#569