Olá, Quando tento executar a função POST no Postman a seguinte mensagem de erra aparece :
Segue a baixo o meu código:
Olá, Quando tento executar a função POST no Postman a seguinte mensagem de erra aparece :
Segue a baixo o meu código:
Voce ta sem a classe Startup?
Veja se os metodos abaixo estao na class Program.cs(.NET6) ou na Startup.cs(.NET5) a depender de qual versao .net voce ta usando.
app.UseAuthentication(); app.UseAuthorization();
using FilmesApi.Data;
using FilmesApi.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
namespace FilmesAPI
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDbContext>(opts => opts.UseLazyLoadingProxies().UseMySQL(Configuration.GetConnectionString("CinemaConnection")));
services.AddControllers();
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
services.AddScoped<CinemaService, CinemaService>();
services.AddScoped<EnderecoService, EnderecoService>();
services.AddScoped<FilmeService, FilmeService>();
services.AddScoped<GerenteService, GerenteService>();
services.AddScoped<SessaoService, SessaoService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}