umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
30 stars 0 forks source link

Exception when posting form via API with active workflow #1003

Closed woodi123 closed 1 year ago

woodi123 commented 1 year ago

A brief description of the issue goes here.

If you have a form with an active workflow (like "Send email") and try to post form data with Postman to the endpoint /umbraco/forms/api/v1.0/entries/{formGuid} the server returns a 500 error with the following stacktrace:

System.InvalidOperationException: Wasn't able to get an UmbracoContext
   at Umbraco.Extensions.UmbracoContextAccessorExtensions.GetRequiredUmbracoContext(IUmbracoContextAccessor umbracoContextAccessor)
   at Umbraco.Cms.Infrastructure.DependencyInjection.UmbracoBuilderExtensions.<>c.<AddCoreInitialServices>b__0_11(IServiceProvider factory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Umbraco.Forms.Core.Services.PlaceholderParsingService.ParseContextPlaceholders(HttpContext context, String value, Hashtable pageElements, Boolean htmlEncodeReplacedValues)
   at Umbraco.Forms.Core.Services.PlaceholderParsingService.ParsePlaceHolders(String value, Boolean htmlEncodeReplacedValues, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.ParseValue(KeyValuePair`2 setting, IPlaceholderParsingService placeholderParsingService, Dictionary`2 typeSettings, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.<>c__DisplayClass1_0.<ParseSettingsPlaceholders>b__1(KeyValuePair`2 x)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.ParseSettingsPlaceholders(IDictionary`2 settings, IPlaceholderParsingService placeholderParsingService, Dictionary`2 typeSettings, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.WorkflowType.ApplySettings(IWorkflow workflow, IPlaceholderParsingService placeholderParsingService, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Services.WorkflowExecutionService.ExecuteWorkflows(List`1 workflows, Record record, Form form, FormState state)
   at Umbraco.Forms.Core.Services.WorkflowExecutionService.ExecuteWorkflows(Record record, Form form, FormState state, Boolean editMode)
   at Umbraco.Forms.Core.Services.RecordService.Submit(Record record, Form form)
   at Umbraco.Forms.Web.Controllers.Api.EntriesController.SubmitEntry(Guid id, FormEntryDto entry)
   at lambda_method2984(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at JsonApiDotNetCore.Middleware.JsonApiMiddleware.InvokeAsync(HttpContext httpContext, IControllerResourceMapping controllerResourceMapping, IJsonApiOptions options, IJsonApiRequest request, ILogger`1 logger) in C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Middleware\JsonApiMiddleware.cs:line 92
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Seems like the problem is this line in the DictionaryHelper while trying to resolve the magic strings: this._httpContextAccessor.HttpContext.RequestServices.GetRequiredService<UmbracoHelper>();

Reproduction

Steps to reproduce

Umbraco Forms: 10.3.0

Expected result

No exception, resolved magic strings.

AndyButland commented 1 year ago

I've been unable to replicate this with the latest code, and so believe we have resolved it with some related work in refactoring this class so it no longer depends on the UmbracoHelper. This was done in relation to issue 989.

Will close and label with the same release and expect this should be resolved with the next minor release of Forms 10+,

cf-marc commented 1 year ago

Hello @AndyButland

I installed the 10.4.0-rc1 of Umbraco Forms and am I still receiving the error if a workflow is added to the form.

System.InvalidOperationException: Wasn't able to get an UmbracoContext
   at Umbraco.Extensions.UmbracoContextAccessorExtensions.GetRequiredUmbracoContext(IUmbracoContextAccessor umbracoContextAccessor)
   at Umbraco.Cms.Infrastructure.DependencyInjection.UmbracoBuilderExtensions.<>c.<AddCoreInitialServices>b__0_11(IServiceProvider factory)
   at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope )
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Umbraco.Forms.Core.Services.PlaceholderParsingService.ParseContextPlaceholders(HttpContext context, String value, Hashtable pageElements, Boolean htmlEncodeReplacedValues)
   at Umbraco.Forms.Core.Services.PlaceholderParsingService.ParsePlaceHolders(String value, Boolean htmlEncodeReplacedValues, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.ParseValue(KeyValuePair`2 setting, IPlaceholderParsingService placeholderParsingService, Dictionary`2 typeSettings, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.<>c__DisplayClass1_0.<ParseSettingsPlaceholders>b__1(KeyValuePair`2 x)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.ParseSettingsPlaceholders(IDictionary`2 settings, IPlaceholderParsingService placeholderParsingService, Dictionary`2 typeSettings, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.WorkflowType.ApplySettings(IWorkflow workflow, IPlaceholderParsingService placeholderParsingService, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Services.WorkflowExecutionService.ExecuteWorkflows(List`1 workflows, Record record, Form form, FormState state)
   at Umbraco.Forms.Core.Services.WorkflowExecutionService.ExecuteWorkflowsWithResult(Record record, Form form, FormState state, Boolean editMode)
   at Umbraco.Forms.Core.Services.WorkflowExecutionService.ExecuteWorkflows(Record record, Form form, FormState state, Boolean editMode)
   at Umbraco.Forms.Core.Services.RecordService.Submit(Record record, Form form)
   at Umbraco.Forms.Web.Controllers.Api.EntriesController.SubmitEntry(Guid id, FormEntryDto entry)
   at lambda_method11(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at JsonApiDotNetCore.Middleware.JsonApiMiddleware.InvokeAsync(HttpContext httpContext, IControllerResourceMapping controllerResourceMapping, IJsonApiOptions options, IJsonApiRequest request, ILogger`1 logger) in C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Middleware\JsonApiMiddleware.cs:line 92
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS
=======
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 74
Content-Type: application/json
Host: xxx
User-Agent: PostmanRuntime/7.32.2
Api-Key: xxx
Postman-Token: xxxx

I think my request is good, because the validation works as excepted. Thanks for your response.

Best regards

AndyButland commented 1 year ago

I've had another look at this @cf-marc, but I'm afraid I'm still having trouble replicating. Are you able to check over my set up and see if you can spot something different that might be relevant?

I've added the default "Contact form" and added a "Send email" workflow. On the latter I've configured the message to be Submitted from [#pageName]. and the subject to be #test ("test" being a dictionary key), so I can check that placeholders are being parsed.

From Postman I'm sending:

{
    "values": {
        "name": "Fred",
        "email": "fred@test.com",
        "comment": "Test",
        "dataConsent": "on"
    },
    "contentId": "4a1f4198-e143-48ba-a0f5-1a7ef2df23aa",
    "culture": "en-US"
}

And I'm finding that's accepted, the entry is saved and the email is sent with the expected replacements.

I expect I'm missing something that would cause the exception you are seeing, but I can't seem to find it at the moment. As I say, can you spot anything in your test case please that might be different here and triggering the issue? Thanks.

cf-marc commented 1 year ago

Thanks @AndyButland for your response. I have a multi language setup (de-CH and fr-CH), I did not mention that before, sorry. Also I was missing the contentId. I am not sure if this is needed. Why do I need the contentId for the API? Anyway, if I add the conentId parameter to my post, I am receiving a new exception. This also happens, when I try to get the definition with the content "/umbraco/forms/api/v1.0/definitions/03f50d24-9c97-4eb0-8906-81924e113ef3?contentId=8858d347-ebca-4009-9044-a55422b78871&culture=de-CH"

System.InvalidOperationException: Wasn't possible to a get a valid Snapshot
   at Umbraco.Extensions.PublishedSnapshotAccessorExtensions.GetRequiredPublishedSnapshot(IPublishedSnapshotAccessor publishedSnapshotAccessor)
   at Umbraco.Cms.Infrastructure.PublishedCache.PublishedContent.get_Parent()
   at Umbraco.Forms.Core.Services.PublishedContentPageService.GetPageElements(IPublishedContent content)
   at Umbraco.Forms.Core.Services.PublishedContentPageService.GetPageElements(Int32 contentId)
   at Umbraco.Forms.Web.Controllers.Api.FormsApiControllerBase.GetContentPageElements(String contentId)
   at Umbraco.Forms.Web.Controllers.Api.DefinitionsController.GetById(Guid id, String contentId, String culture)
   at lambda_method4683(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at JsonApiDotNetCore.Middleware.JsonApiMiddleware.InvokeAsync(HttpContext httpContext, IControllerResourceMapping controllerResourceMapping, IJsonApiOptions options, IJsonApiRequest request, ILogger`1 logger) in C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Middleware\JsonApiMiddleware.cs:line 92
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
AndyButland commented 1 year ago

contentId if there's a need to parse placeholders related to the "current page".

I'm afraid I've not been able to replicate still though. The only thing I can see is different from your stack trace is the inclusion of JsonApiDotNetCore. Might well be unrelated but is it possible for you to disable that see see if it has any effect?

cf-marc commented 1 year ago

Thanks @AndyButland, I removed the JsonApiDotNetCore from Startup.

System.InvalidOperationException: Wasn't able to get an UmbracoContext
   at Umbraco.Extensions.UmbracoContextAccessorExtensions.GetRequiredUmbracoContext(IUmbracoContextAccessor umbracoContextAccessor)
   at Umbraco.Cms.Infrastructure.DependencyInjection.UmbracoBuilderExtensions.<>c.<AddCoreInitialServices>b__0_11(IServiceProvider factory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Umbraco.Forms.Core.Services.PlaceholderParsingService.ParseContextPlaceholders(HttpContext context, String value, Hashtable pageElements, Boolean htmlEncodeReplacedValues)
   at Umbraco.Forms.Core.Services.PlaceholderParsingService.ParsePlaceHolders(String value, Boolean htmlEncodeReplacedValues, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.ParseValue(KeyValuePair`2 setting, IPlaceholderParsingService placeholderParsingService, Dictionary`2 typeSettings, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.<>c__DisplayClass1_0.<ParseSettingsPlaceholders>b__1(KeyValuePair`2 x)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at Umbraco.Forms.Core.Extensions.DictionaryExtensions.ParseSettingsPlaceholders(IDictionary`2 settings, IPlaceholderParsingService placeholderParsingService, Dictionary`2 typeSettings, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.WorkflowType.ApplySettings(IWorkflow workflow, IPlaceholderParsingService placeholderParsingService, Record record, Form form, Hashtable pageElements)
   at Umbraco.Forms.Core.Services.WorkflowExecutionService.ExecuteWorkflows(List`1 workflows, Record record, Form form, FormState state)
   at Umbraco.Forms.Core.Services.WorkflowExecutionService.ExecuteWorkflowsWithResult(Record record, Form form, FormState state, Boolean editMode)
   at Umbraco.Forms.Core.Services.WorkflowExecutionService.ExecuteWorkflows(Record record, Form form, FormState state, Boolean editMode)
   at Umbraco.Forms.Core.Services.RecordService.Submit(Record record, Form form)
   at Umbraco.Forms.Web.Controllers.Api.EntriesController.SubmitEntry(Guid id, FormEntryDto entry)
   at lambda_method10(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS
=======
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 175
Content-Type: application/json
Host: x
User-Agent: PostmanRuntime/7.32.2
X-API-Key: 
Api-Key: x
Postman-Token: f2da0f92-7d33-4148-a9c7-4ecdfaf88c2b
cf-marc commented 1 year ago

Thanks @AndyButland for your support. I removed the complete JSON API Setup from Startup.cs. In the end it had to do with "app.UseRouting();" and "app.UseEndpoints(configure: endpoints => endpoints.MapControllers());". You can close the issue.

AndyButland commented 1 year ago

A-ha, well good to hear. I must admit it was baffling me so I'm glad you sorted it.