Home > database >  Error showing while using RestSharp RestClient method
Error showing while using RestSharp RestClient method

Time:03-22

My API is calling REST API using RestSharp and Code looks like this

    var runRequest = { Contains my JSON}
    var client = new RestClient(".....");
    var request = new RestRequest("....", Method.Post);
    string AuthHeader = "...";

    request.AddParameter("application/json", runRequest, ParameterType.RequestBody);
    request.AddParameter("Authorization", "Bearer "   AuthHeader, ParameterType.HttpHeader);
    var response = client.Execute(request); <---- {Red line showing under client}
    return Ok(response);

Error

enter image description here

Because of that red line, I am not able to run my program. Can somebody please tell what the issue can be ?

Thank you

CodePudding user response:

You are using the latest RestSharp version. All the sync methods were deprecated as RestSharp uses HttpClient under the hood, and HttpClient doesn't have any sync overloads, everything is async.

You can find a list of changed or deprecated members of RestClient in the documentation.

  • Related