'Problem when sending Post request from C#

I am trying to send POST request from C# and get the "token" key from the response.

here is my code:

public static void Main(string[] args)
        {

            var timestamp = DateTime.Now.AddHours(-3).ToString("yyyy-MM-dd HH:mm:ss.fffZ");


            var nonce = Guid.NewGuid().ToString();

            var hmac = GetHMAC("key" + nonce + timestamp, "secret");
            var signature = Base64Encode(hmac);


            var url = "URL" + "/v1/authenticate";

            var httpRequest = (HttpWebRequest)WebRequest.Create(url);
            httpRequest.Method = "POST";

            httpRequest.ContentType = "application/json";

            JObject o = new JObject();

            o["client_key_id"] = "key";
            o["timestamp"] = timestamp;
            o["nonce"] = nonce;
            o["signature"] = signature;

            var data = o.ToString();

            using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
            {
                streamWriter.Write(data);
            }

            try
            {
                var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                }

                Console.WriteLine(httpResponse.StatusCode);
            }
            catch (Exception ex)
            {
                var v = ex.Message;
            }


        }

I am getting error 400 (bad request). When executed in postman i get this response :

{
    "error_message": "[Bad Request] Validation error for body application/json: Provided value don't match pattern, input: /properties/timestamp"
}

Do you know how I can fix that ?

The original code snippet is written on python and there it works like a charm. I am posting a screenshot of the python code. Do you have any suggestions how this could be solved ?

enter image description here



Sources

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

Source: Stack Overflow

Solution Source