I have gone through the http://restsharp.org/ code which work greats. Below is the code of RestSharp with out asp.net core .
public GenericResponseObject<T> GetGeneric<T>(string operation, params KeyValuePair<string, string>[] nameValues) where T : class
{
RestClient client = new RestClient(_baseUrl)
{
Authenticator = new HttpBasicAuthenticator(_username, _password)
};
RestRequest request = new RestRequest(operation, Method.GET);
foreach (KeyValuePair<string, string> nameValue in nameValues)
{
request.AddQueryParameter(nameValue.Key, nameValue.Value);
}
IRestResponse<GenericResponseObject<T>> response = client.Execute<GenericResponseObject<T>>(request);
GenericResponseObject<T> responseObject = response.Data;
return responseObject;
}
}
This code works great to me. Now I want to implement same code in asp.net core.
Can I get a sample example how to use RestSharp in asp.net core. I have added the dependency RestSharp.NetCore": 105.2.3.
RestSharp v106 supports .NET Standard so your code should work without changes.
RestSharp.NetCore
package is not from RestSharp team and is not supported by us. It is also not being updated and the owner does not respond to messages, neither the source code of the package is published.