次のようなAPIエンドポイントがあります
[HttpPost("create")]
[MapToApiVersion("1.0")]
public async Task<IActionResult> Post(CarDto carDto)
{
return Ok(await _carService.CreateCarAsync(carDto));
}
以下の Dto は、コントラクトを含む nuget パッケージで共有される do です。
public class CarDto
{
[JsonProperty(PropertyName = "Id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "Colour")]
public string Colour{ get; set; }
}
コンソール アプリの呼び出しコード
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);
私が得る例外は次のとおりです
値の解析中に予期しない文字が検出されました: {. パス ''、行 1、位置 1。
Http get の呼び出しは正常に機能するため、上記のセットアップで何かが間違っています