Setting BaseURI for named HttpClient in DI not including trailing string
I am trying to use a named HttpClient setup in a Blazor WASM application. In my DI setup, I create it using the following:
However, when the HttpClient is injected into a Razor page and used to query my API using this code: it makes a request like so:
It seems to be dropping the "/api/v1/" portion of the base URI for the request but using the base host/port that I provided (the port running this web application is 5000, which I assume would be the HttpClient default if I hadn't provided a new BaseAddress in my configuration.)
Why is it dropping this portion and how can I get it to stop?
1 Reply
Apparently, when using the HttpClient, my requestUri had a leading slash ("/Chores") and HttpClient was getting messed up trying to combine it with my BaseAddress for some reason. Removing the slash from my HttpClient's Get request fixes this issue.
I was fixated on the configuration and didn't think that I may just be misusing the client. A bit confusing but all is well.