How to receive JSON data on WebAPI backend C#?

前端 未结 4 1280
独厮守ぢ
独厮守ぢ 2020-12-08 07:19

How do I receive JSON data on my WebAPI backend in C#?

I have the following JSON sent from my JavaScript frontend.

{
    \"User_Id\": 1,
    \"T         


        
4条回答
  •  Happy的楠姐
    2020-12-08 07:44

    The Content-Type of your request should be "application/json"

    If you post your json in a body of the request than change a method signature to

    [HttpPost]
    public bool AddOrder([FromBody] PurchaseOrder order)
    {
    }
    

提交回复
热议问题