1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-08 00:16:27 +00:00

Fix requestBodyFormat parameter usage

This commit is contained in:
JKorf 2023-12-02 15:15:38 +01:00
parent 0987c0f9d1
commit d43b38a23a

View File

@ -515,7 +515,7 @@ namespace CryptoExchange.Net
if (parameterPosition == HttpMethodParameterPosition.InBody) if (parameterPosition == HttpMethodParameterPosition.InBody)
{ {
var contentType = requestBodyFormat == RequestBodyFormat.Json ? Constants.JsonContentHeader : Constants.FormContentHeader; var contentType = bodyFormat == RequestBodyFormat.Json ? Constants.JsonContentHeader : Constants.FormContentHeader;
if (bodyParameters.Any()) if (bodyParameters.Any())
WriteParamBody(request, bodyParameters, contentType); WriteParamBody(request, bodyParameters, contentType);
else else
@ -533,13 +533,13 @@ namespace CryptoExchange.Net
/// <param name="contentType">The content type of the data</param> /// <param name="contentType">The content type of the data</param>
protected virtual void WriteParamBody(IRequest request, SortedDictionary<string, object> parameters, string contentType) protected virtual void WriteParamBody(IRequest request, SortedDictionary<string, object> parameters, string contentType)
{ {
if (requestBodyFormat == RequestBodyFormat.Json) if (contentType == Constants.JsonContentHeader)
{ {
// Write the parameters as json in the body // Write the parameters as json in the body
var stringData = JsonConvert.SerializeObject(parameters); var stringData = JsonConvert.SerializeObject(parameters);
request.SetContent(stringData, contentType); request.SetContent(stringData, contentType);
} }
else if (requestBodyFormat == RequestBodyFormat.FormData) else if (contentType == Constants.FormContentHeader)
{ {
// Write the parameters as form data in the body // Write the parameters as form data in the body
var stringData = parameters.ToFormData(); var stringData = parameters.ToFormData();