'The request I get 200 in Postman but gives 400 in the code

I get 400 on code but Postman returns 200 for the same request. I couldn't find the source of the problem. I take the json in the code and paste it into Postman and it works. Do you have any solution suggestions for this? Could there be a place I missed? MY codes:

public async Task<TokenResponse> GetAccessToken()
{
    try
    {
        var credential = new CredentialInfos
        {
            ssl_merchant_id = "0026031",
            ssl_pin = "IEWYZSNWRTQQLEPAXXL3UXUPNAXSX7KCLBOPCWUKNZG1QLQD3QIG4II6OUQWZ88C",
            ssl_user_id = "apiuser287390",
            ssl_transaction_type = "ccsale",
            ssl_invoice_number = "5550",
            ssl_vendor_id = "sc963003",
            ssl_amount = "10"
        };

        if (credential != null)
        {
            var request = new RequestBase()
            {

                Url = $"https://api.demo.convergepay.com/hosted-payments/transaction_token",
                HttpMethod = HttpMethod.Post,
                Data = credential
            };

            var httpResponse = await _httpHandler.ProcessRequest(request);

            if (httpResponse.IsSuccessful && httpResponse.StatusCode == HttpStatusCode.OK)
            {
                var response = JsonSerializer.Deserialize<TokenResponse>(httpResponse.Data);

                if (response.expiresInSec > 0)
                {
                    return await Task.FromResult(response);
                }
            }
            throw new Exception("Error!");

        }
    }
    catch (Exception)
    {
        return await Task.FromResult(new TokenResponse());
    }
    throw new Exception("Error");
}

And this

public async Task<ResponseBase> ProcessRequest(RequestBase request)
{
    HttpResponseMessage httpResponse;
    string responseText;

    try
    {

        var jsonData = JsonSerializer.Serialize(request.Data);
        var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.Url);
        httpRequestMessage.Content = request.Data != null ? new StringContent(jsonData, Encoding.UTF8, "application/json") : null;
        httpRequestMessage.Headers.Authorization = request.Authorization ?? null;

        if (request.HeaderParameters != null)
        {
            foreach (KeyValuePair<string, string> parameter in request.HeaderParameters)
            {
                httpRequestMessage.Headers.Add(parameter.Key, parameter.Value);
            }
        }

        httpResponse = await _httpClient.SendAsync(httpRequestMessage);
        responseText = await httpResponse.Content.ReadAsStringAsync();
    }
    catch (Exception ex)
    {
        return await Task.FromResult(new ResponseBase() { Data = string.Empty, StatusCode = HttpStatusCode.InternalServerError, IsSuccessful = false, ExceptionMessage = ex?.Message });
    }

    var result = new ResponseBase() { Data = responseText, StatusCode = httpResponse.StatusCode, IsSuccessful = true };

    return await Task.FromResult(result);
}

Postman Input and Outputs

Json Data

Header



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source