Azure / Azure/azure-functions-core-tools
Call Function from Logic App Standard gives error BadRequest. Http request failed: 'An item with the same key has already been added. Key: Code'.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 498
- Avg merge
- 5d 4h
- Merged PRs (30d)
- 15
Description
Using **VS Code** and **Azure Logic App Standard** extension to build a Standard Logic App locally.
Using **Azure Functions Core Tools** for local runtime:
Core Tools Version: **3.0.3904** Commit hash: c345f7140a8f968c5dbc621f8a8374d8e3234206 (64-bit)
Function Runtime Version: **3.3.1.0**
Calling an **Azure Function** deployed in Azure from the local Logic App, I get the error below. The function is still invoked and runs OK, but the Logic App Run Instance UI reports a BadRequest on the function invoke.

```
Job warning: correlationId='8b7c9843-2534-4e87-b8f4-520665bacdf2', operationName='FlowHttpEngine.GetErrorMessageFromException', jobPartition='C3B3EB386CA441A59ECADDB92E819CE9:2D08585654968131582416188788881CU00', jobId='08585654968131582416188788881CU00', message='Http request failed with exception of type 'ArgumentException' and message exception: 'An item with the same key has already been added. Key: Code'.', exception='System.ArgumentException: An item with the same key has already been added. Key: Code
[2021-11-05T11:01:25.209Z] at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
[2021-11-05T11:01:25.210Z] at System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection>.Add(KeyValuePair`2 keyValuePair)
[2021-11-05T11:01:25.211Z] at Microsoft.WindowsAzure.ResourceStack.Common.Extensions.ICollectionExtensions.AddRange[T](ICollection`1 source, IEnumerable`1 values)
[2021-11-05T11:01:25.212Z] at Microsoft.Azure.Workflows.Data.Extensions.UriExtensions.WithAdditionalQueryParameters(Uri uri, QueryStringDictionary queryParameters)
[2021-11-05T11:01:25.213Z] at Microsoft.Azure.Workflows.Data.Extensions.HttpRequestMessageExtensions.AddQueryStringAuth(HttpRequestMessage request, HttpQueryStringAuthentication authentication, ICommonEventSource logger)
[2021-11-05T11:01:25.213Z] at Microsoft.Azure.Workflows.Data.Extensions.HttpRequestMessageExtensions.PopulateRequestAuthentication(HttpRequestMessage request, HttpAuthentication authentication, OAuthTokenCacheProvider tokenProvider, ICommonEventSource logger)
[2021-11-05T11:01:25.214Z] at Microsoft.Azure.Workflows.Data.Engines.FlowHttpEngine.CallHttpEndpoint(ICommonEventSource logger, FlowAuthentication flowAuthentication, HttpAuthentication httpAuthentication, Nullable`1 operationOptions, HttpRequestMessage request, LoadBalancedHttpClientConfiguration configuration, OAuthTokenCacheProvider tokenProvider, CancellationToken cancellationToken, String operationName, Boolean allowTrustedRootCertificateThumbprints)
[2021-11-05T11:01:25.215Z] at Microsoft.Azure.Workflows.Worker.Jobs.FunctionActionJob.OnExecuteRetryableAction(FlowRunActionExecutionContext actionExecutionContext, FunctionActionInput actionInput, FlowOperationState operationState)', organizationId='', activityVector='IN.09', additionalProperties='', extensionVersion='1.0.0.0', siteName='UNDEFINED_SITE_NAME', slotName='', activityId='bffa8923-c3b7-443d-8f02-fcb09a9ffcfd'.
```
Contributor guide
Research direction
No repository files or tests are named. Reproduce the local Logic App Standard invocation with the listed VS Code, Azure Functions Core Tools, and runtime versions, then trace the stack entries through AddQueryStringAuth, PopulateRequestAuthentication, and CallHttpEndpoint. Done means the function invocation no longer reports BadRequest with a duplicate Code key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, vscode
- Domain
- cloud, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100