Closed xayaraj closed 1 year ago
The {id}
does not work, you can just use a wildcard string: /api/users/*
. Can you try that ?
It works. Thank you.
Is there a way to retrieve the id which is 123 value and respond it back in the body as shown above?
That would be possible using:
request.PathSegments.[<n>]
--> URL path segment (zero indexed) e.g. request.PathSegments.[2]
Awesome. Thank you.
Describe the bug
With the url /api/user/{id} endpoint where id is the path variable. I have created the WireMock.Net server to listen for the given url path for Http incoming request.
Server:
_server .Given(Request.Create().WithPath("/api/users/{id}").UsingGet()) .RespondWith(Response.Create().WithStatusCode(200).WithBody("User {id}"));
Client: var client = new HttpClient(); var response = await client.GetAsync($"{_server.Urls[0]}/api/users/123"); var content = await response.Content.ReadAsStringAsync();
Response receive is 404 Not found
It might a simple stupid mistake or something that I have missed. Any help is appreciated. Thanks.