1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-20 12:53:02 +00:00

Added support for Patch requests, added SetBody to ParameterCollection for directly setting the request body

This commit is contained in:
JKorf
2024-06-04 09:54:24 +02:00
parent 4b6fa9a1b1
commit 8080ecccc0
5 changed files with 52 additions and 5 deletions
+7 -2
View File
@@ -75,7 +75,8 @@ namespace CryptoExchange.Net.Clients
{ HttpMethod.Get, HttpMethodParameterPosition.InUri },
{ HttpMethod.Post, HttpMethodParameterPosition.InBody },
{ HttpMethod.Delete, HttpMethodParameterPosition.InBody },
{ HttpMethod.Put, HttpMethodParameterPosition.InBody }
{ HttpMethod.Put, HttpMethodParameterPosition.InBody },
{ new HttpMethod("Patch"), HttpMethodParameterPosition.InBody },
};
/// <inheritdoc />
@@ -804,7 +805,11 @@ namespace CryptoExchange.Net.Clients
if (contentType == Constants.JsonContentHeader)
{
// Write the parameters as json in the body
var stringData = CreateSerializer().Serialize(parameters);
string stringData;
if (parameters.Count == 1 && parameters.ContainsKey(Constants.BodyPlaceHolderKey))
stringData = CreateSerializer().Serialize(parameters[Constants.BodyPlaceHolderKey]);
else
stringData = CreateSerializer().Serialize(parameters);
request.SetContent(stringData, contentType);
}
else if (contentType == Constants.FormContentHeader)