Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error thrown when using Authorize parameter #1016

Closed
dansharpe83 opened this issue Dec 14, 2020 · 1 comment · Fixed by #1034
Closed

[BUG] Error thrown when using Authorize parameter #1016

dansharpe83 opened this issue Dec 14, 2020 · 1 comment · Fixed by #1034
Labels

Comments

@dansharpe83
Copy link

dansharpe83 commented Dec 14, 2020

Describe the bug
I get an error when trying to do a basic post, it has an object serialized to the body and a bearer token.
my class is:
interface IDataFinitiApi { [Post("/businesses/search")] Task<DataFinitiSearchResult<BusinessRecord>> SearchCompanies([Body]DataFinitiRequest request, [Authorize("Bearer")] string token); }

my test app is this:
`var s = RestService.For("https://api.datafiniti.co/v4", settings);

        var query = new DataFinitiRequest { Query = "postalCode:ST3 2NS" };

        var result = s.SearchCompanies(query, apiKey).GetAwaiter().GetResult();`

when i go over the result line, i get the following error:
The given key '1' was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException[T](T key)
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Refit.RequestBuilderImplementation.<>c__DisplayClass18_0.<<BuildRequestFactoryForMethod>b__0>d.MoveNext() in /_/Refit/RequestBuilderImplementation.cs:line 621 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at Refit.RequestBuilderImplementation.<>c__DisplayClass14_02.<<BuildCancellableTaskFuncForMethod>b__0>d.MoveNext() in /_/Refit/RequestBuilderImplementation.cs:line 240 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at DataFinitiPoC.Program.Main(String[] args) in DataFinitiPoC\Program.cs:line 27

i think is is because in the RequestBuilderImplementation.cs, on line 618, is adds the bearer token, but doesnt mark it as mapped, so it falls into the loop underneath, which is where the error occurrs.

this is a netcore console app, using v6.0.0-preview.37 of refit

@dansharpe83 dansharpe83 changed the title [BUG] Summary of item [BUG] Error thrown when using Authorize parameter Dec 15, 2020
@clairernovotny clairernovotny linked a pull request Jan 24, 2021 that will close this issue
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant