Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
how to send array of object to server. Asp.Net Core 3.1 405 Method Not Allowed

I am trying to send array of object to web Api post ActionResult method. my array of objects looks like this

'[{"TitleFeature":"عنوان یک","ValueFeature":"مقداریک","IdProduct":"1"},{"TitleFeature":"عنوان یک","ValueFeature":"مقداریک","IdProduct":"1"}]'

enter image description here

my function JS looks like this

const uri = '/api/Feature/PostFeatures';
        const baseURL = window.location.origin;
        var dataFeature = getFeature();
        var features = JSON.stringify(dataFeature);

        $.ajax({
            contentType: "application/json",
            dataType: 'json',
            type: "POST",
            url: (baseURL + uri),
            data: features,
        });

my Controller.cs is looks like this

[HttpPost]
    [AllowAnonymous]
    public async Task<ActionResult<Feature>> PostFeatures([FromBody] List<Feature> features)
    {
        if (features != null)
            foreach (var item in features)
            {
                _context.features.Add(item);
            }
        await _context.SaveChangesAsync();

        return Ok();
    }

I use Role Based authorization and this is my role:

[Route("api/[controller]")]
[ApiController]
[Authorize(Roles = "admin")]
public class FeatureController : ControllerBase

how to fix error 405?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

The 405 error means that you have entered the URL but the http request does not match, so if there is no route attribute on your action method, you can try to change the ajax request address to .../api/Feature

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda