我可以通过这样做添加到 JSON 正文中:
_request.AddJsonBody(obj1);
_request.AddJsonBody(obj2);
我怎样才能清除 body ?没有 RemoveJsonBody()
方法或任何类似的方法。
最佳答案
您可以使用:
_request.Parameters.Clear();
清除请求正文中的所有参数。
或
_request.Parameters.RemoveAt(1);
删除特定索引处的元素。
或
你可以尝试一下,只删除 RequestBody 类型并保留标题:
_request.Parameters.RemoveAll(x => x.Type == RestSharp.ParameterType.RequestBody);
关于c# - Restsharp.RestRequest.RemoveJsonBody() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32219141/