Restsharp.RestRequest.RemoveJsonBody()

Restsharp.RestRequest.RemoveJsonBody()

我可以通过这样做添加到 JSON 正文中:

_request.AddJsonBody(obj1);
_request.AddJsonBody(obj2);

如何清理尸体?没有 RemoveJsonBody() 方法或任何类似的方法。

您可以使用:

_request.Parameters.Clear();

清除请求中的所有参数body。

_request.Parameters.RemoveAt(1);

删除特定索引处的元素。

你可以尝试一下,只删除 RequestBody 类型并保留 headers:

_request.Parameters.RemoveAll(x => x.Type == RestSharp.ParameterType.RequestBody);