我试图将POST请求发送到Azure中托管的WebAPI终结点,并且它仅返回400 Bad Request。发送到本地主机的请求完全相同。我已经在Postman和Fiddler中对此进行了测试,我无法解释。我每次都发送完全相同的有效负载。我只是更改基本网址。我什至还添加了Swagger并尝试通过那里发布具有相同结果的结果。这是endpoint。
控制器
[HttpPost("api/location/post")]
[AllowAnonymous]
public async Task<IActionResult> Post([FromBody]Models.Input.NewLocationInput location)
{
try
{
_logger.LogInformation("Adding new location: Name: {0}
await _service.Add(newlocation);
return Ok();
}
catch(Exception ex)
{
_logger.LogError(ex.ToString());
throw ex;
}
}
NewLocationInput
public class NewLocationInput
{
public string name { get; set; }
public string placeId { get; set; }
public double lat { get; set; }
public double lon { get; set; }
public string phone { get; set; }
public string address { get; set; }
}
json正文
{
"name":"YMCA at the Athenaeum",
"placeId":"ChIJu8tmVOtQa4gRf6Hh2KtoA30",
"lat":39.7736162,"lon":-86.149838699999989,
"phone":"+1 317-685-9705",
"address":"401 E Michigan St #3, Indianapolis, IN 46204, USA"
}
提前谢谢!!!!