Questions tagged [refit]

Refit is a library heavily inspired by Square's Retrofit library, and it turns your REST API into a live interface.

Refit is a .NET library heavily inspired by Square's Retrofit library (JAVA), and it turns your REST API into a live interface. Read more on refit at Github.

204 questions
3
votes
1 answer

How to override Refit's implementation of an interface method?

I recently discovered the convenience of using Refit, but after reading through its documentation I was unable to find a way to replace/override an implementation of an interface method that RestService would normally generate. Does Refit provide a…
Lukas
  • 1,699
  • 1
  • 16
  • 49
3
votes
0 answers

OAuth2 flows using Refit with Asp Net Core 2.1

Well, I have a WebApi using Asp Net Core 2.1 that have some security endpoints, so I have the following: services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; …
Ronaldo Lanhellas
  • 2,975
  • 5
  • 46
  • 92
3
votes
3 answers

DateTime loses precision when serialized and used as a url parameter using Refit

I'm building an API Gateway that got an endpoint that takes DateTime value as a parameter. It forwards this query to an underlying microservice using Refit. My problem is that when the URL for the query to the microservice is built, the DateTime…
Øystein
  • 1,163
  • 1
  • 12
  • 23
3
votes
0 answers

Refit: Is there a way to send a list of complex object in query

Trying to send request using Refit to controller: [HttpGet("api/users/{userId}/appointments")] public async Task Get(Guid userId, [FromQuery] FilterRow[] filters = null) {} Added interface with this…
3
votes
0 answers

How to implement Jwt authentication with the refit library and have it to cache the bearer token for a certain duration?

I'm writing a .net core console application to run a set of background jobs. The jobs target a Rest API so I'm using Refit library. The library is quite straightforward but for the authentication part it's a little bit unclear how to achieve it in…
Isser Zack
  • 39
  • 3
3
votes
1 answer

How to add a static authorization header with refit in xamarin.forms?

i'm trying to add a static authorization Header with basic authentication, but when i do the request, the server response is negative. So, i tried to add it in this way: [Headers("Authorization: Basic","Content-Type:…
Giuseppe Pennisi
  • 396
  • 3
  • 22
3
votes
0 answers

Add Custom TypedClient with Refit

I am having issue when adding a custom client with Refit. I dont want default httpClient. The reason to do is that I dont want my consumers to change httpclient configuration when they are consuming my refit implemented Client. Separation of…
Kamran Pervaiz
  • 1,861
  • 4
  • 22
  • 42
3
votes
1 answer

How to share service method URL between Refit and Web API?

I have written a C# interface and compiled it into Contract.dll. The Contract.dll is referenced by an ASP.NET MVC website (the client in this scenario) and an ASP.NET Web API service. I use Refit in the website to call the service. I tried using a…
Erik Madsen
  • 497
  • 6
  • 17
3
votes
1 answer

Best retry policy for Refit ApiException?

I´m using both Refit and Polly to call to restful API´s and I´m wondering what the retry (if any) policy for Refits ApiException should be? public static PolicyWrap MyRetryPolicy() { // Try few times with little more time between... maybe…
Sturla
  • 3,446
  • 3
  • 39
  • 56
3
votes
0 answers

Concurrent HttpClient calls throwing 500 internal server error

I'm using Refit with 1-2 interfaces and generate my client RESTful classes for Web API requests. public interface IApiClient where T : new() { [Get("")] Task> GetInitialOrUpdatedData(string clientId); } In…
George Taskos
  • 8,324
  • 18
  • 82
  • 147
2
votes
1 answer

How do I log HTTP requests when using Refit in .net core?

I want to use Refit to query an API. First thing, I need to obtain an access token which is a POST request returning a status 400. I have no idea what causes the problem, thus I would like to see the actual raw request that is being sent to the API.…
Aileron79
  • 523
  • 5
  • 27
2
votes
1 answer

Unable to refresh token in Refit with Polly retry

I am trying to use Polly retry policy for handling unauthorised responses which require a token refresh. But I seem to be stuck in a loop. So the unauthorised error is captured and processed by Polly, I call a method to refresh the token which works…
jason.kaisersmith
  • 8,712
  • 3
  • 29
  • 51
2
votes
1 answer

How to unit test the Refit ApiResponse?

I'm using refit to call APIs and the response is wrapped in ApiResonse. I can mock the refit call that returns a mocked ApiResponse and assert. Everything works as it should except I'm not sure how I can test the api call that returns an…
Stack Undefined
  • 1,050
  • 1
  • 14
  • 23
2
votes
2 answers

System.Text.Json in Refit can't handle null response from API

Suppose I have a Refit interface: public interface SomeApi { [Get("/DoStuff")] Task DoStuff(); } I register this refit client in my dependency injection with System.Text.Json: services.AddRefitClient(new RefitSettings( …
yesman
  • 7,165
  • 15
  • 52
  • 117
2
votes
1 answer

How do I add a Polly policy to a Refit Client created with a factory?

I have a refit client (IMyRefitClient) that returns Task> I can't inject this refit client in Program.cs with HostBuilder.ConfigureServices because the url isn't known until runtime. Therefore, I'm using a factory class…
Jack
  • 237
  • 1
  • 4
  • 14
1 2
3
13 14