Tags down


How to use HttpClientFactory with AutoRest generated client

By : Yabo Jia
Date : October 18 2020, 06:10 AM
To fix the issue you can do You'll need to use a named client, rather than a typed client, and then you'll need to register your AutoRest client using the factory overload.
code :
services.AddHttpClient("MyAutoRestClient", c =>
    // configure your HttpClient instance

services.AddScoped<MyAutoRestClient>(p =>
    var httpClient = p.GetRequiredService<IHttpClientFactory>().GetClient("MyAutoRestClient");
    // get or create any other dependencies
    // set disposeHttpClient to false, since it's owned by the service collection
    return new MyAutoRestClient(credentials, httpClient, false);

Share : facebook icon twitter icon

Different client output when used Autorest.exe vs ADD->Rest API Client

By : Joshua Melse
Date : March 29 2020, 07:55 AM
wish helps you I finally figured out the issue. I was using a different version of Autorest.exe to generate my client where as Visual Studio "Add -> Rest API Client" is using another version. After I downloaded the version needed and used the same command above, it worked like charm.

How do I get JWT working in Autorest generated SDK? (ASP.NET Core 2.0)

By : Feh
Date : March 29 2020, 07:55 AM
I hope this helps . Finally it is working. I found a tip at Andrei Dzimchuk's blog on setting up the token
code :
using System;
using System.Threading.Tasks;
using Microsoft.Rest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using swagger;
using swagger.Models;

namespace CoreClientTest
    public class MyTests
        public void TestMethod1()
            catch (Exception e)

        private static async Task<JobHeader> GetMyJob()
            var tokenRequest = new TokenRequest
                Username = "myusername",
                Password = "mypassword"
            var credentials = new TokenCredentials("bearer token");
            var uri = new Uri("https://localhost:44348", UriKind.Absolute);
            var tokenClient = new Track3API(uri, credentials);
            var tokenResponse = await tokenClient.ApiRequestTokenPostWithHttpMessagesAsync(tokenRequest);
            var tokenContent = await tokenResponse.Response.Content.ReadAsStringAsync();
            var tokenString = JObject.Parse(tokenContent).GetValue("token").ToString();
            var creds2 = new TokenCredentials(tokenString);
            var client2 = new Track3API(uri, creds2);
            var result = await client2.ApiJobsByIdGetWithHttpMessagesAsync(1);
            string resultContent = await result.Response.Content.ReadAsStringAsync();
            var job = JsonConvert.DeserializeObject<JobHeader>(resultContent);
            return job;


How to make CORS API call from Blazor client app with authentication using AutoRest Client?

By : user3050246
Date : March 29 2020, 07:55 AM
Does that help I am trying to call Web API from Blazor Client App. The API sends required CORS headers and works fine when I call the API using plain Javascript. , This is not really the answer... I just need space

How to pass client certificate using AutoRest client

By : Efraím Perez
Date : March 29 2020, 07:55 AM
it should still fix some issue We are using AutoRest for generating client code based on API Swagger files. , You can use another overloaded constructor:

Can I use an Autorest client in blazor

By : SpartanD39
Date : March 29 2020, 07:55 AM
seems to work fine Yes it is possible. But you have to use the HttpClient that is injected by the blazor framework as described here:
code :
public partial class YourApi : ServiceClient<YourApi>, IYourApi
public partial class YourApi
    public void SetHttpClient(HttpClient client) {
        this.HttpClient = client;
Related Posts Related Posts :
  • Convert HTML to PDF using HTML Renderer using C# and XML to Pdf
  • Conversion failed when converting varchar value to datatype bit
  • How to edit an XML file in Streamingassets from my hololens
  • Naming a DispatcherTimer based on a string from another method?
  • How to call the default browser in the Hololens app
  • How do I close an IF statement if there is no more code to be executed with 'else'?
  • Unity3D: Is there a easy way to give a min/max to a value in the inspector?
  • The type or namespace name 'ICloudRecoEventHandler' could not be found
  • When compiling C# expression trees into methods, is it possible to access "this"?
  • Sort an array of strings in ascending order in C#
  • How detect is a method in a C# class is implementing a method from an interface?
  • How to parse a timespan in order to add it to a datetime?
  • Changing code from if-statement to switch-statement in C#
  • Linq GroupBy Clause not including items with zero count
  • How to determine the highest value in a list of properties
  • C# Custom Json.NET List serialization
  • Session Variable is null after using RedirectToAction
  • How to manipulate c# code programatically In .Net Core?
  • Modifying Windows System sounds
  • Is there a way to convert this powershell script to C#
  • Lists will show null even though assigned in constructor
  • Any way to have a `using` block that doesn't define a scope block?
  • How do I get a result from this mocked service?
  • async await losing response in c#
  • How can I pause an execution without using Thread.Sleep()
  • How to Stop In Azure Ad Authentication Sign Out ask for Which account do you want to sign out of?
  • Use operators with and without space in c#
  • Remove duplicates from comma separated list
  • Use a String variable as argument from if sentence
  • unity how to avoid scaling heritage when parenting?
  • Is there a way to do nested model binding with the [FromBody] attribute?
  • How to insert dynamic query into table using c#
  • Why Unit Testing Assert.AreEqual() method does NOT pick up my own Equals() method in the customized class
  • Unity Error: Feature 'out variable declaration'
  • What happens if my C# switch expression is non-exhaustive?
  • How Can I Select an ItemTemplate Based on a Value?
  • EF Class table name and column have same name
  • Substring issues - input string was not in a correct format
  • C# Asynchronously read data from a redirected StandardOutput
  • The code after await operation is not executing
  • Image FILL logic such as "Stretch.Uniform" of WPF
  • Why am I allowed to declare a variable with the same name?
  • Simplest way to display colored 3D boxes in winforms
  • Conventions on having both an API and MVC project in .NET Core solution
  • File upload .NET Core 'IFormFile' does not contain a definition for 'CopyToAsync' and no extension method
  • Deserialize only valid objects by ignoring errors
  • How to write into text file what is ordered by years
  • Remove this 'return' statement or make it conditional
  • Cannot implicitly convert type "System.DateTime" to "LearnScan.LearnUser.NullableDateTime"
  • Why does DateTime.UtcNow.Subtract give me a massive number sometimes?
  • How to restart CancellationTokenSource after make it cancel in c#?
  • Same data is fetched from the database every time
  • JSON Deserialize is not working with List object
  • Convert Visual Studio 2017 C# solution / project for use with Mono on Linux?
  • Sort list by multiple variables
  • How valid is it to use `Result` inside `Task.Run`
  • how to put a variable in the image source in C# like we do in php
  • How to display an image stored in database as bytes into a View?
  • MVC issue for accessing the data from database:The parameters dictionary contains a null entry for parameter 'id' of non
  • Is there a method to group 4 controls into an UserControl or template and use it in parent UserControl and bind them wit
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk