C# 将字符串转换为RestSharp定义的调用方法
所以我尝试使用RestSharp,创建一个处理所有事情的函数,然后单独调用它,而不是每次都使用RestSharp中的每个函数。 我遇到的问题是在RestRequest方法中使用字符串参数作为定义C# 将字符串转换为RestSharp定义的调用方法,c#,restsharp,C#,Restsharp,所以我尝试使用RestSharp,创建一个处理所有事情的函数,然后单独调用它,而不是每次都使用RestSharp中的每个函数。 我遇到的问题是在RestRequest方法中使用字符串参数作为定义 public void GetRestClient(string country, string method, string endpoint, string body = null) { string url = getCountryUrl(country) + e
public void GetRestClient(string country, string method, string endpoint, string body = null)
{
string url = getCountryUrl(country) + endpoint;
RestClient client = new RestClient(url);
RestRequest getRequest = new RestRequest(Method.**method**);
}
这是个好办法吗
RestRequest getRequest = new RestRequest((Method)Enum.Parse(typeof(Method), method));
这起到了作用:
RestRequest getRequest = new RestRequest((Method)Enum.Parse(typeof(Method), method));