Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var request = new RestRequest("some/where", Method.POST); // Create a new request
- request.RequestFormat = DataFormat.Json; // The request data is JSON
- request.AddBody(parameters); // parameters is a dictionnary object, so it is serialized as a JSON string by Restclient
- request.AddHeader("Content-Type", "application/json"); // Make sure that the request is detected as a JSON by the server
- string body = request.Parameters.Find(param => param.Type == ParameterType.RequestBody).Value.ToString(); // Get the raw request body
- request.Parameters.RemoveAll(param => param.Type == ParameterType.RequestBody); // Remove this body from the request
- // Perform some operation to this raw body
- // Adding back the modified body to the request
- request.RequestFormat = DataFormat.Json;
- request.AddParameter("application/json", body, ParameterType.RequestBody);
Advertisement
Add Comment
Please, Sign In to add comment