-
-
Notifications
You must be signed in to change notification settings - Fork 770
Open
Labels
Description
Describe the bug 🐞
When using both [Property] and [Query] attributes on method parameters, the query parameters are not added to the request URI, while path parameters work as expected. This behavior blocks our testing setup where we need both:
- [Property] to access parameter values in test handlers
- [Query] to add parameters to the request URI
Environment:
- Refit 8.0.0
- Refit.Newtonsoft.Json
Step to reproduce
ITestApi:
public interface ITestApi
{
[Get("/{value1}")]
Task DoWork(
[Property("value1")] string value1,
[Property("value2")][Query] string value2,
[Query] string value3,
CancellationToken cancellationToken);
}
DebugHandler:
public class DebugHandler : DelegatingHandler
{
public DebugHandler(HttpMessageHandler innerHandler)
: base(innerHandler)
{
}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var uri = request.RequestUri;
var options = request.Options;
Debugger.Break();
return await base.SendAsync(request, cancellationToken);
}
protected override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken)
{
var uri = request.RequestUri;
var options = request.Options;
Debugger.Break();
return base.Send(request, cancellationToken);
}
}
Program:
using var handler = new DebugHandler(new HttpClientHandler());
using var httpClient = new HttpClient(handler);
httpClient.BaseAddress = new Uri("https://www.google.de/");
var api = RestService.For<ITestApi>(httpClient);
await api.DoWork("1", "2", "3", CancellationToken.None);
Uri:
Note: The path parameter is correctly replaced in the route, only the query parameters are affected.
I would expect:
Reproduction repository
No response
Expected behavior
Parameters should be accessible via Properties AND added to request URI when both attributes are present.
Screenshots 🖼️
No response
IDE
No response
Operating system
No response
Version
No response
Device
No response
Refit Version
8.0.0
Additional information ℹ️
This issue is blocking our test phase starting next week. We need either:
- A quick fix or simple workaround
- An estimated timeline for a framework fix to help plan our approach
I just discovered this during testing today, apologies for the urgent notice - you know how these things go!