Hi, I was successful to implement a consumer unit ...
# pact-net
c
Hi, I was successful to implement a consumer unit test involving a method sending a HttpMethod.Delete request and a parameter. The request works if the request path is without the name of the parameter as follows:
Copy code
.WithRequest(HttpMethod.Delete, "/api/products/13")
But if I change the path to include the parameter name as follows, the request fails:
Copy code
.WithRequest(HttpMethod.Delete, "/api/products?id=13")
In this case the HttpClient.DelectAsnyc() method returns the following error:
Copy code
{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
 Access-Control-Allow-Origin: *
 x-pact: Unexpected-Request
 Date: Wed, 16 Mar 2022 11:23:47 GMT
 Content-Type: application/json; charset=utf-8
 Content-Length: 329
}}
Does Pact.NET mock provider not support named parameters in the request query?
m
In other languages, the query string is a separate part of the DSL
so it shouldn’t be part of the path (the path doesn’t include the query string)
c
Thank you very much, as you suggested the mock provider responds as expected after using .WithRequest() in combination with .WithQuery(): .WithRequest(HttpMethod.Delete, "/api/products") .WithQuery("id", "13")
👍 1