I have an api endpoint as follows
[HttpPost("create")]
[MapToApiVersion("1.0")]
public async Task<IActionResult> Post(CarDto carDto)
{
return Ok(await _carService.CreateCarAsync(carDto));
}
The Dto below is a shared do in nuget package with contracts
public class CarDto
{
[JsonProperty(PropertyName = "Id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "Colour")]
public string Colour{ get; set; }
}
My calling code in the Console app
public interface ICarServiceApi
{
[Post("/Cars/create")]
Task<bool> CreateCar(CarDto carDto);
}
var carServiceApi = RestService.For<ICarServiceApi>("https://localhost:5001/api/v1");
var car = new CarDto {Id ="123", Colour = "Red"};
await carServiceApi.CreateCar(car);
The exception i get is as follows
Unexpected character encountered while parsing value: {. Path '', line 1, position 1.
The call to the Http get works fine so something is wrong in my setup above