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)
{
SetParams(@params);
SetHeaders(headers);
try
{ await _client?.ExecuteAsync(_request, method); }
catch (Exception exception)
{ Console.WriteLine(exception.ToString()); }
finally
{ _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?
Sign in to answer