I got the below exception when implementing the POST method
[2022-06-17T07:14:41.723Z] Executed 'Functions.AuthenticateHttpTrigger' (Failed, Id=12bb7c91-4030-4090-a2fe-ec205702c662, Duration=424954ms)
[2022-06-17T07:14:41.726Z] System.Private.CoreLib: Exception while executing function: Functions.AuthenticateHttpTrigger. System.Private.CoreLib: Result: Failure
Exception: System.InvalidOperationException: Duplicate binding call detected. Input parameters can only be bound to arguments once. Use the InputArguments property to inspect values.
[2022-06-17T07:14:41.727Z] at Microsoft.Azure.Functions.Worker.Context.Features.DefaultModelBindingFeature.BindFunctionInput(FunctionContext context) in D:\a\1\s\src\DotNetWorker.Core\Context\Features\DefaultModelBindingFeature.cs:line 29
[2022-06-17T07:14:41.728Z] at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\a\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionExecutor.cs:line 37
[2022-06-17T07:14:41.729Z] at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
Have you encountered an issue like that? please advise.
Thanks in advance.
============================================
EDIT
Here is my function definition
[AllowAnonymous]
[Function(nameof(AuthenticateHttpTrigger))]
[OpenApiOperation(operationId: nameof(AuthenticateHttpTrigger), Description = "Authenticate")]
[OpenApiRequestBody(contentType: Constants.CommonResponseContentType, bodyType: typeof(AuthenticationRequest))]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: Constants.CommonResponseContentType, bodyType: typeof(AuthenticationResponse), Description = "The OK response")]
public async Task<HttpResponseData> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "authenticate")] HttpRequestData req, FunctionContext executionContext)
{
try
{
_logTrace.Add(LogLevel.Info, $"{nameof(AuthenticateHttpTrigger)} - AUTHENTICATE START", new { });
var requestUser = executionContext.Features.Get<JwtPrincipalFeature>()?.User;
var requestData = await req.GetBodyAsync<AuthenticationRequest>();
var addUserCommand = new AuthenticateCommand
{
RequestUser = requestUser,
Data = requestData,
LogTrace = _logTrace
};
return await _httpFunctionExecutor.ExecuteAsync(async () =>
{
var result = await _mediator.Send(addUserCommand);
_logTrace.Add(LogLevel.Info, $"{nameof(AuthenticateHttpTrigger)} - AUTHENTICATE END ", new { result });
return result.Success
? CreateResponse(HttpStatusCode.OK, req, result.Data)
: CreateResponse(HttpStatusCode.UnprocessableEntity, req, null);
}, req);
}
catch (Exception e)
{
_logTrace.AddError(e);
return CreateResponse(HttpStatusCode.UnprocessableEntity, req, null);
}
finally
{
_logTrace.Flush();
}
}