简体   繁体   中英

Web API Null Content C# from Postman

Trying this so hard. Been calling a function API from Postman but when I tried to check the content it is null and the method is GET but I have set to POST.

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Here is the receiving code

  [System.Web.Http.HttpPost()]
        // POST: Stream_Technical
        public void Update_Activation(HttpRequestMessage request)
        {
            

      
        
            string message = request.Content.ReadAsStringAsync().Result;
            

        }

Change your method like this

   [HttpPost("collection")]
    // POST: Stream_Technical
    public void Update_Activation([FromBody]HttpRequestMessage request)
    {



        string s = JsonConvert.SerializeObject(request);
      //  string message = request.Content.ReadAsStringAsync().Result;


    }

Here I also attached a screen shot在此处输入图像描述

post man request在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM