C# POST请求中raw 参数的传递

  public static string PostmanPost()
        {
            var client = new RestClient("http://119.3.248.64:3000");
            var request = new RestRequest(Method.POST);
            request.RequestFormat = DataFormat.Json;
            request.AddHeader("Content-Type", "application/json");
//            request.AddParameter("undefined", "{\"ddd\":\"eee\"}", ParameterType.RequestBody);

            Rootobject bean = new Rootobject("console","test");


            request.AddParameter("application/json; charset=utf-8", JsonConvert.SerializeObject(bean), ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);
            var responseContent = response.Content;
            return responseContent;
        }

 

posted @ 2019-11-19 14:49  GLORY-HOPE  阅读(10084)  评论(0编辑  收藏  举报