Refit: [BUG] An item with the same key has already been added. Key: 2

Created on 19 Aug 2019  路  4Comments  路  Source: reactiveui/refit

Describe the bug
Refit intarface:

[Get("/queues/{id}/export")]
        Task<string> GetQueueAsync([Header("Authorization")] string authorization,
                                            [AliasAs("id")] long id,
                                            [AliasAs("format")] string format,
                                            [AliasAs("page")] int page,
                                            [AliasAs("status")] [Query(CollectionFormat.Csv)] IEnumerable<string> filters);

failt with:

`System.ArgumentException: An item with the same key has already been added. Key: 1`
`   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at Refit.RestMethodInfo..ctor(Type targetInterface, MethodInfo methodInfo, RefitSettings refitSettings) in D:\a\1\s\Refit\RestMethodInfo.cs:line 46
   at Refit.RequestBuilderImplementation.AddInterfaceHttpMethods(Type interfaceType, Dictionary`2 methods) in D:\a\1\s\Refit\RequestBuilderImplementation.cs:line 77
   at Refit.RequestBuilderImplementation..ctor(Type refitInterfaceType, RefitSettings refitSettings) in D:\a\1\s\Refit\RequestBuilderImplementation.cs:line 56
   at Refit.RequestBuilderFactory.Create[T](RefitSettings settings) in D:\a\1\s\Refit\RequestBuilderFactory.cs:line 18
   at Refit.RestService.For[T](HttpClient client, RefitSettings settings) in D:\a\1\s\Refit\RestService.cs:line 28
   at ConsoleApp1.Program.Main(String[] args)`

Steps To Reproduce

static void Main(string[] args)
 {
    var apiService = RestService.For<IApiService>("http://xyz.com");
    var result = apiService.GetQueueAsync(1, "xml", ImportStates());            
}

private static IEnumerable<string> ImportStates()
{
   var states = new List<string>();
   states.Add("Postponed");
   states.Add("Split");
   states.Add("ToReview");
   return states;
}

Environment

  • OS: .net core 2.2 on Win10
  • Version 4.7.9

Additional context
Same Refit interface works in 4.6.107.

bug outdated

Most helpful comment

can confirm that in my case it solved the problem

All 4 comments

Can you try the latest release please? 4.7.51 has just been published to Nuget.

can confirm that in my case it solved the problem

Excellent, glad to hear this can be closed. 馃檪

Can you try the latest release please? 4.7.51 has just been published to Nuget.

It working in my case, thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hiraldesai picture hiraldesai  路  4Comments

jstafford5380 picture jstafford5380  路  4Comments

eduardocampano picture eduardocampano  路  6Comments

omares picture omares  路  6Comments

mary-perret-1986 picture mary-perret-1986  路  5Comments