I am creating A Restful API (Using Visual Basic/C#)
I have a Class/Model with a single field
public class ResultsiMeter
{
[JsonProperty("id")]
[JsonPropertyName("id")]
public int id { get; set; }
}
My Controller
[Route("api/[controller]")]
[HttpPost]
public void Post([FromBody] ResultsiMeter resultsiMeter)
{
return;
}
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
My get request actually hits the spot
GET http://localhost:63719/Api/iMeterResults HTTP/1.1
Accept-Encoding: gzip,deflate
Host: localhost:63719
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/16.0.2)
and returns the 2 values
When I Fire off a POST request
POST http://localhost:63719/Api/iMeterResults HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/json;charset=UTF-8
Content-Length: 19
Host: localhost:63719
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/16.0.2)
{
"id": 12345
}
I receive a 400 response which appears to suggest a structure issue ??
application/problem+json; charset=utf-8, 185 bytes
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "Bad Request",
"status": 400,
"traceId": "00-7bf623aeedb0abf41a13dd0a5e87a045-48a6258679cea4d5-00"
}
I cannot for the life of me see what is wrong.
The JSon is very simple and appears to be constructed correctly
Can anyone put a newbie numpty on the right path as I am flumoxed
Thanks in advance for any advice offered
Iain