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
6
votes
2 answers

How can I pass a list of strings within a request?

I'm using Refit library for my app and I need to make a call to another service. I need to get all entities with ids that I'm passing. I tried [Body] attribute and it still doesn't work. I manage to pass a request but the list if ids that another…
Sofia Bo
  • 679
  • 1
  • 10
  • 20
6
votes
3 answers

Request new access token and resubmit the api request

I am using the Refit library with my Xamarin forms project to send API requests. It works great, but have an issue when the access token expires. When the access token expires, I get an 401 error from the server, as expected. I then make a call to…
Libin Joseph
  • 7,070
  • 5
  • 29
  • 52
6
votes
3 answers

Refit [FromQuery] with custom class not getting values

I'm having a problem with a Get method in my Web API: The API gets the object but with the default values. For instance: myRefitClient.GetSummary(new MyClass() { Prop = 1 }); The Web API correctly receives a MyClass instance, but Prop is 0! This is…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
6
votes
3 answers

How to disable urlencoding get-params in Refit?

I use Refit for RestAPI. I need create query strings same api/item?c[]=14&c[]=74 In refit interface I created method [Get("/item")] Task GetTenders([AliasAs("c")]List categories=null); And create…
Dmitry
  • 1,095
  • 14
  • 21
6
votes
2 answers

Pass json params in get requests

I have: public class Query {...} public interface IClient { [Get("/api/endpoint?data={query}")] Task GetData(Query query); } but Refit on the Query instance calls ToString instead of using the serializer. Is there any way to achieve…
Mark Toman
  • 3,090
  • 2
  • 17
  • 18
5
votes
1 answer

Refit - Use refit parameters (string) to pass as controller parameters

There is a way to use Refit to input parameters in a dynamic way? I have this code in my Refit`s Interface: [Get("/click?{parm}")] Task> SaveClick(string parm); the value of parm is: "id=1234&x=567" my route: …
5
votes
1 answer

How to upload files using NET CORE and Refit

When I use a POSTMAN to do make a request, my API receives a IList. How can I do the same request using Xamarin.Forms with REFIT?
Matheus Velloso
  • 175
  • 1
  • 9
5
votes
2 answers

Call API using Refit and deserialize to dynamic

I'm calling a REST service using Refit and I want to deserialize the JSON that is returned as a dynamic type. I tried defining the interface as [Get("/foo")] Task GetFoo(); but the call times out. I know I can deserialize to a dynamic…
Steve Chadbourne
  • 6,873
  • 3
  • 54
  • 82
5
votes
1 answer

How do I set the User-Agent at runtime with refit?

If my user agent is a constant string, I can use [Headers("User-Agent: Awesome Octocat App")] to set it. However, My user agent is generated by a method (because it includes the device and OS version), which means I can't put it inside the Headers…
copolii
  • 14,208
  • 10
  • 51
  • 80
4
votes
1 answer

Refit AliasAs does not work for deserialize

Just wonder what is the proper way to use AliasAs in deserializing a response in ReFit? The code below will correctly parse a response if the variable name in the model is the same as in the response, but the returned value will be null if the…
Chu Bun
  • 513
  • 1
  • 5
  • 17
4
votes
2 answers

C# Refit client is not sending authorization header

I'm using a C# Refit client to have my services talk to one another via http. I'm trying to send a Bearer token through the Authorization header, but according to the error message, it's not setting the AZ header in the request (see bottom). I've…
DLeh
  • 23,806
  • 16
  • 84
  • 128
4
votes
1 answer

ASP.NET Core Refit Client for RESTful API: How to divide clients

I'm currently building a client for a RESTful API with ASP.NET Core 5 and Refit (using HttpClientFactory). What I'm a little confused about, is how to divide the API interfaces (how many separate interfaces to write for different API…
4
votes
0 answers

Projects using Refit cannot build using MSBuild '16.6.0'. MSBuild '16.8.0' or later is required

I am trying to build a Xamarin project with Refit 6.0 via the command line. I tried to compile the .Net Standard project with dotnet build and the Xamarin.Android project with msbuild. dotnet build demo/demo.csproj msbuild /t:Build…
Martin Ryan
  • 61
  • 1
  • 5
4
votes
1 answer

Xamarin PCL Refit 3.0.1 , Doesn't look like a Refit interface

I recently started working on a Xamarin Android/iOS project with a PCL class where I want to put all the logic in. Like my Refit interfaces, ReactiveUI ViewModels et cetera, but every time when trying to execute my code I get a error saying that my…
3
votes
0 answers

Refit API Client - Mix Body and Queryparameters in single object

When using the Refit REST Library to build a client targeting an asp.net based api is it possible to mix Query and Body items in a single Custom Object? Example Asp.Net Route [Route("documents/{id}")] public void PostDocument(int id, [FromBody]…
Grant Trevor
  • 1,052
  • 9
  • 23
1
2
3
13 14