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

300
Views
Error de lanzamiento de cartero para solicitud POST y PUT: RestAPI C# Unity

He codificado RestAPI con .NET. Estoy usando Postman para probar la API. Me está dando una solicitud http exitosa para OBTENER y ELIMINAR. Pero lanzando un error para la solicitud PUT y POST.

A continuación se muestran los códigos que estoy usando para crear RestAPI.

Código: Player.cs

 using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace UnityRestAPI.Contracts { [JsonObject, Serializable] public class Player { public int Id { get; set; } public string FullName { get; set; } public float Score { get; set; } } }

Código: PlayersController.cs

 using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; using UnityRestAPI.Contracts; namespace UnityRestAPI.Controllers { [Route("api/[controller]")] [ApiController] public class PlayersController : Controller { private static List<Player> Players = new List<Player>() { new Player { Id = 1, FullName = "Michael Jordan", Score = 1000 }, new Player { Id = 2, FullName = "Steve Jobs", Score = 2000 }, new Player { Id = 3, FullName = "Carton John", Score = 3000 }, }; // GET api/players [HttpGet] public JsonResult Get() { return Json(Players); } // GET api/players/5 [HttpGet("{id}")] public JsonResult Get(int id) { Player player = Players.Single(p => p.Id == id); return Json(player); } // POST api/players [HttpPost] public JsonResult Post([FromBody]Player newPlayer) { Players.Add(newPlayer); return Json(Players); } // PUT api/players/5 [HttpPut("{id}")] public JsonResult Put(int id, [FromBody] float newScore) { Player player = Players.Single(p => p.Id == id); player.Score = newScore; return Json(player); } // DELETE api/players/5 [HttpDelete("{id}")] public void Delete(int id) { Player player = Players.Single(p => p.Id == id); Players.Remove(player); } } }

Solicitud RestAPI GET en Postman: Solicitud exitosa

Error de cartero para solicitud POST en cartero: entrada no válida

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

es un problema de tipo RAW, intente cambiar lo siguiente ingrese la descripción de la imagen aquí

Para

ingrese la descripción de la imagen aquí

over 4 years ago · Santiago Trujillo 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!