reactiveui/refit · error · ArgumentException
MethodName exists more than once, 'parameterTypes' mut be de
Error message
MethodName exists more than once, 'parameterTypes' mut be defined
What it means
An interface method name maps to more than one HTTP-attributed overload, but the caller did not supply parameterTypes to disambiguate. The resolver cannot pick between overloads on its own, so it demands the parameter type array. (The message has a known typo: 'mut' instead of 'must'.)
Source
Thrown at src/Refit.Reflection/RequestBuilderImplementation.cs:382
/// <exception cref="InvalidOperationException">None of the overloads accept <paramref name="parameterTypes"/> once closed over <paramref name="genericArgumentTypes"/>.</exception>
[RequiresUnreferencedCode("Resolving generic Refit methods from reflected metadata requires generic method metadata to be available at runtime.")]
[RequiresDynamicCode("Resolving generic Refit methods from reflected metadata requires runtime generic method instantiation.")]
internal RestMethodInfoInternal FindMatchingRestMethodInfo(
string key,
Type[]? parameterTypes,
Type[]? genericArgumentTypes)
{
if (!_interfaceHttpMethods.TryGetValue(key, out var httpMethods))
{
throw new ArgumentException(
"Method must be defined and have an HTTP Method attribute");
}
if (parameterTypes is null)
{
if (httpMethods.Count > 1)
{
throw new ArgumentException(
$"MethodName exists more than once, '{nameof(parameterTypes)}' mut be defined");
}
return CloseGenericMethodIfNeeded(httpMethods[0], genericArgumentTypes);
}
var possibleMethods = FilterPossibleMethods(httpMethods, parameterTypes, genericArgumentTypes);
if (possibleMethods.Length == 1)
{
return CloseGenericMethodIfNeeded(possibleMethods[0], genericArgumentTypes);
}
foreach (var method in possibleMethods)
{
try
{
var closedMethod = CloseGenericMethodIfNeeded(method, genericArgumentTypes);View on GitHub (pinned to b455f65ecc)
Solutions
- Supply the parameterTypes argument when resolving the method so the overload can be disambiguated.
- If you control the interface, rename one overload or drop the duplicate attribute so only one HTTP overload of that name remains.
- Differentiate overloads with distinct HTTP routes/verbs instead of identical names.
Example fix
// before
public interface IApi {
[Get("/items/{id}")] Task<Item> GetAsync(int id);
[Get("/items/{slug}")] Task<Item> GetAsync(string slug); // ambiguous name
}
// after (distinct names)
public interface IApi {
[Get("/items/{id}")] Task<Item> GetByIdAsync(int id);
[Get("/items/{slug}")] Task<Item> GetBySlugAsync(string slug);
} Defensive patterns
Strategy: validation
Validate before calling
// Disambiguate overloads by supplying parameter types when resolving.
var info = builder.FindMatchingRestMethodInfo(nameof(IApi.GetAsync), new[] { typeof(int) }, null); Prevention
- Avoid two HTTP-attributed overloads with the same name.
- Differentiate overloads by distinct routes or names.
- When resolving by name, always pass parameterTypes.
When it happens
Trigger: Calling an overloaded Refit method name through a code path that resolves by name only (e.g. some dynamic/generated invokers) where two overloads both carry HTTP attributes, without supplying the argument type list.
Common situations: Two overloads of the same method name both annotated with HTTP attributes; refactoring that added an overload; using a Refit extension that resolves by name only.
Related errors
- targetInterface must be an Interface
- Method must be defined and have an HTTP Method attribute
- No suitable Method found...
- Sequence contains no elements
- Sequence contains more than one matching element
AI-assisted analysis of reactiveui/refit@b455f65ecc (2026-08-13).
Data as JSON: /api/errors/7f0dd9c27f3e256b.
Report an issue: GitHub.