Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why get URL scheme "https+http" is not supported. #479

Closed
neozhu opened this issue Nov 22, 2024 · 2 comments
Closed

why get URL scheme "https+http" is not supported. #479

neozhu opened this issue Nov 22, 2024 · 2 comments
Labels
Status: No Recent Activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question

Comments

@neozhu
Copy link

neozhu commented Nov 22, 2024

in my aspire project : https://github.com/neozhu/cleanaspire
what should I do? Please give me some advice.

builder.Services.AddHttpClient("apiservice", client =>
{
    // This URL uses "https+http://" to indicate HTTPS is preferred over HTTP.
    // Learn more about service discovery scheme resolution at https://aka.ms/dotnet/sdschemes.
    client.BaseAddress = new("https+http://apiservice");
}
).AddHttpMessageHandler<CookieHandler>();
builder.Services.AddSingleton<ApiClient>(sp =>
{
    ApiClientBuilder.RegisterDefaultSerializer<JsonSerializationWriterFactory>();
    ApiClientBuilder.RegisterDefaultSerializer<TextSerializationWriterFactory>();
    ApiClientBuilder.RegisterDefaultSerializer<FormSerializationWriterFactory>();
    ApiClientBuilder.RegisterDefaultSerializer<MultipartSerializationWriterFactory>();
    ApiClientBuilder.RegisterDefaultDeserializer<JsonParseNodeFactory>();
    ApiClientBuilder.RegisterDefaultDeserializer<TextParseNodeFactory>();
    ApiClientBuilder.RegisterDefaultDeserializer<FormParseNodeFactory>();
    var settings = sp.GetRequiredService<IOptions<ClientAppSettings>>().Value;
    var httpClientFactory = sp.GetRequiredService<IHttpClientFactory>();
    var httpClient = httpClientFactory.CreateClient("apiservice");
    var authProvider = new AnonymousAuthenticationProvider();
    var requestAdapter = new HttpClientRequestAdapter(authProvider, httpClient: httpClient);
    var apiClient = new ApiClient(requestAdapter);
    //if (!string.IsNullOrEmpty(settings.ServiceBaseUrl))
    //{
    //    requestAdapter.BaseUrl = settings.ServiceBaseUrl;
    //}
    return apiClient;

});

Image

Image

@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Nov 22, 2024
@baywet
Copy link
Member

baywet commented Nov 25, 2024

Hi @neozhu
Thank you for using kiota and for reaching out.

Am I correct that if you uncomment the lines setting the base url on the request adapter it start working properly?

Also, it should work properly if you do not set that "special value" in the http client base url, correct?

The base Url from the http client is read in the request adapter and passed to the RFC 6570 uri template in order to resolve the final URL.

Looking at the documentation link from the comment. Additionally, it seems that there should at least be a call to AddServiceDiscovery so things can be resolved (and I wonder whether they are resolved by a middleware handler during the request execution or ahead of that)

@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question labels Nov 25, 2024
@baywet baywet moved this from Needs Triage 🔍 to Waits for author 🔁 in Kiota Nov 25, 2024

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@neozhu neozhu closed this as completed Dec 2, 2024
@github-project-automation github-project-automation bot moved this from Waits for author 🔁 to Done ✔️ in Kiota Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: No Recent Activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:question An issue that's a question
Projects
Status: Done ✔️
Development

No branches or pull requests

2 participants