RestSharp POST request keep staying in WaitingForActivation

Максим Егоров 1 Reputation point

Here's my code which make an POST request

public static void PostInformation()
        HttpRequests httpRequests = new(_apiUrl);

        Dictionary<string, string> @params = new() { };
        Dictionary<string, string> headers = new() { };

        var httpRequest = async () =>
            await httpRequests.SendRequest(@params, headers, RestSharp.Method.Post);
        var request = httpRequest();

private static RestClient? _client;
private static RestRequest? _request;

public HttpRequests(string url)
    _client = new RestClient(url);
    _request = new RestRequest();

public async Task SendRequest(Dictionary<string, string> @params, 
                                             Dictionary<string, string> headers, Method method)

        { await _client?.ExecuteAsync(_request, method); }
        catch (Exception exception)
        { Console.WriteLine(exception.ToString()); }
        { _client?.Dispose(); }

        return null;

And after running this code, the request status stops at WaitinigForActivation, so my question is, could this be because of the wrong JSON sent from the Dictionary named @params, or is there some other issue?

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,535 questions
{count} votes