Mautic 3 - c# authentication issue: The client credentials are invalid

Anybody work on Mautic api with c# or asp.net core?

I’m checking it on localhost for Mautic production one. I got below error even I have pass correct credentials. I have checked with both Get/Post requests.

It throws:

{"errors":[{"message":"The client credentials are invalid","code":400,"type":"invalid_client"}]}

I found related issue here: but it didn’t help

Code:

        try
        {
            using (var client = new HttpClient())
            {
                var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:8012/mautic/oauth/v2/token");
                    request.Content = new FormUrlEncodedContent(new Dictionary<string, string> {
                    { "client_id", "key" },
                    { "client_secret", "secret" },
                    { "grant_type", "authorization_code" },
                    { "redirect_uri", Uri.EscapeUriString("http://localhost")},
                    { "code", DateTime.Now.ToString("ddMMyyyyHHmmss") }
                });

                var authenticationBytes = Encoding.ASCII.GetBytes("admin:123qwe");

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                        Convert.ToBase64String(authenticationBytes));

                var response = await client.SendAsync(request);
                

                var responsestring = await response.Content.ReadAsStringAsync();
                var payload = JObject.Parse(responsestring);
                var token = payload.Value<string>("access_token");
            }

        }
        catch (System.Exception ex)
        {
            Console.WriteLine(ex.Message);
        }