ASP.NET Core Mvc how to pass query params by default to named HttpClients?

328 Views Asked by At

I have a preconfigured base url for my named HttpClientFactory, but I also want to pass an api_key as query param to it by default, are there options to do it, or how would I do it in general?

//Just some setup stuff here...
builder.WebHost.UseUrls("https://localhost:5003");
... add Services
var mvcBuilder = builder.Services.AddRazorPages();

how to add query params?

builder.Services.AddHttpClient(name: "MoviesDBClient", 
    configureClient: options =>
    {
    options.BaseAddress = new Uri("https://api.themoviedb.org/3/");
    options.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(
    "application/json", 1.0));
    });

because the api.themoviedb.org requires my api_key and I don't want to append it to the url every time again...

0

There are 0 best solutions below