elsa-workflows / elsa-workflows/elsa-core

ELSA 3.1.3 Getting Error when i call get /workflow-definitions endpoint

Open
#5,573 2 comments 0 reactions 0 assignees View on GitHub
bug triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

I am implementing ELSA workflow 3.1.3 in my projects.
I have two separate project APIProject(Server) and FrontEndUI(Blazor) project. My API have token based authentication in my API project.
I have added the all the required libraries in my project and i am using the MongoDB as a storage provider.
`try
{
var builder = WebApplication.CreateBuilder(args);

builder.Host.AddConfigurations();
builder.Host.UseSerilog((ctx, lc) => lc.ReadFrom.Configuration(ctx.Configuration) );

//builder.Services.AddControllers().AddFluentValidation();
builder.Services.AddControllers();
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(typeof(Program).GetTypeInfo().Assembly));
builder.Services.AddApplication();

#region ELSA 3.1
var NoSQLConnectionStringWothoutReplicaset = builder.Configuration.GetSection("DatabaseSettings").GetSection("NoSQLConnectionStringWothoutReplicaset").Value;
builder.Services.AddElsa(elsa =>
{
Elsa.EndpointSecurityOptions.DisableSecurity();
elsa.UseMongoDb(NoSQLConnectionStringWothoutReplicaset);
// Default Identity features for authentication/authorization.
elsa.UseWorkflowManagement(manage =>
{
manage.UseMongoDb();
});
elsa.UseWorkflowRuntime(runtime =>
{
runtime.UseMongoDb();
});

// Expose Elsa API endpoints.
elsa.UseWorkflowsApi(api => api.AddFastEndpointsAssembly());

// Setup a SignalR hub for real-time updates from the server.
elsa.UseRealTimeWorkflows();

// Enable C# workflow expressions
elsa.UseCSharp();
elsa.UseJavaScript();

// Enable HTTP activities.
elsa.UseHttp();

// Register custom activities from the application, if any.
elsa.AddActivitiesFrom();

// Register custom workflows from the application, if any.
elsa.AddWorkflowsFrom();
});

builder.Services.AddNotificationHandlersFrom();

// Configure CORS to allow designer app hosted on a different origin to invoke the APIs.
builder.Services.AddCors(cors => cors
.AddDefaultPolicy(policy => policy
.AllowAnyOrigin() // For demo purposes only. Use a specific origin instead.
.AllowAnyHeader()
.AllowAnyMethod()
.WithExposedHeaders("x-elsa-workflow-instance-id"))); // Required for Elsa Studio in order to support running workflows from the designer. Alternatively, you can use the `*` wildcard to expose all headers.

// Add Health Checks.
builder.Services.AddHealthChecks();

#endregion

var app = builder.Build();

await app.Services.InitializeDatabasesAsync();
app.MapEndpoints();

app.UseCors();
app.UseRouting();
app.UseAuthorization();
app.UseHttpsRedirection();
app.UseWorkflowsApi(); // Use Elsa API endpoints.
app.UseWorkflows(); // Use Elsa middleware to handle HTTP requests mapped to HTTP Endpoint activities.
app.UseWorkflowsSignalRHubs();
app.MapControllers();
app.Run();

}
catch (Exception ex) when (!ex.GetType().Name.Equals("HostException", StringComparison.Ordinal))
{
StaticLogger.EnsureInitialized();
Log.Fatal(ex, "Unhandled exception");
}
finally
{
StaticLogger.EnsureInitialized();
Log.Information("Server Stopping");
Log.CloseAndFlush();
}`

But when i try to call the API end point i am getting below Error.
**{
"messages": [
"Unable to resolve service for type 'Elsa.Persistence.IWorkflowDefinitionStore' while attempting to activate 'Elsa.Server.Api.Endpoints.WorkflowDefinitions.List'."
],
"source": "****.*****.KeyValidatorMiddleware+d__2",
"exception": "Unable to resolve service for type 'Elsa.Persistence.IWorkflowDefinitionStore' while attempting to activate 'Elsa.Server.Api.Endpoints.WorkflowDefinitions.List'.",
"errorId": "7c47c8a5-abba-44e3-85ec-2cb819dadbe5",
"supportMessage": "exceptionmiddleware.supportmessage",
"statusCode": 500
}**

![image](https://github.com/elsa-workflows/elsa-core/assets/12658787/708c1a56-93c8-4af5-a85f-a5c1560eeddd)

Can any help me please with this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.