Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
cómo enviar una matriz de objetos al servidor. Método Asp.Net Core 3.1 405 no permitido

Estoy tratando de enviar una matriz de objetos al método web Api post ActionResult. mi matriz de objetos se ve así

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

ingrese la descripción de la imagen aquí

mi función JS se ve así

 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, });

mi Controller.cs se ve así

 [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(); }

Uso la autorización basada en roles y este es mi rol:

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

¿Cómo reparar el error 405?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

El error 405 significa que ingresó la URL pero la solicitud http no coincide, por lo que si no hay un atributo de ruta en su método de acción, puede intentar cambiar la dirección de la solicitud ajax a .../api/Feature

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!