沫沫1023 2017-05-23 02:57 采纳率: 40%
浏览 2528
已采纳

请问如何使用RestSharp向接口发送无参数名的数据

请问如何使用RestSharp向接口发送无参数名的数据
请问哪位大侠知道啊,请不吝赐教啊

  • 写回答

2条回答 默认 最新

  • 沫沫1023 2017-05-25 09:13
    关注

    已解决,上代码

    var client = new RestClient(uri);
    var request = new RestRequest(method, Method.POST);

                //传递无参数名的参数例如: "eyJhZGxIn0="(加密后的字符串)
                request.AddParameter("application/json; charset=utf-8", paramData, ParameterType.RequestBody);
    
                // execute the request
                IRestResponse response = client.Execute(request);
    
                //连不上接口时,不会触发catch异常,但ErrorException字段不为NULL
                if (response.ErrorException != null)
                    throw response.ErrorException;
    
                string content = response.Content; // raw content as string
                return content;
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?