I'm trying to work with a simple Web API method. When I POST
to this I see in Visual Studio's debugger that the method was hit, and cartItemId
is populated correctly. But my second parameter, quantity
is null
.
Here's the Web API:
[HttpPost]
[Route("api/Cart/{cartItemId}")]
[ResponseType("200", typeof(ResponseObject<CartItemDomainModel>)), ResponseType("500", typeof(Exception))]
public async Task<IHttpActionResult> UpdateQuantity(int cartItemId, [FromBody]string quantity)
{
var result = await _cartService.UpdateCartItemQuantity(cartItemId, Convert.ToInt32(quantity));
return ...;
}
Here's what Postman is sending:
POST /api/Cart/1 HTTP/1.1
Host: localhost:51335
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 5d4a40f1-794d-46fd-1776-2e0c77979f4a
{
"quantity":"5"
}