Skip to content
Discussion options

You must be logged in to vote

A few updates, and a working approach.

First, QueryAttribute and ParameterAttribute are not sealed in current Refit. The change you saw was not kept, so subclassing is possible again - but you do not need it for this.

To send a complex object as a single JSON-valued query parameter (instead of having Refit flatten it into separate keys), you have two clean options:

  1. Serialize to a string yourself and pass it as a string parameter. This is the simplest and most explicit:
public interface IApi
{
    [Get("/search")]
    Task<Result> Search([Query] string filter);
}

// call site
var filter = JsonSerializer.Serialize(new { name = "abc", tags = new[] { 1, 2 } });
await api.Search(filter);

Th…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by glennawatson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants