Reputation: 101
So I'm trying to use RestSharp and create a function that handles everything and then call it alone, instead of using every single function in restsharp everytime. What I'm having trouble with is having a String parameter be used as a definition inside Method of RestRequest.
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**);
}
Would this be a good way?
RestRequest getRequest = new RestRequest((Method)Enum.Parse(typeof(Method), method));
Upvotes: 1
Views: 1197
Reputation: 101
This worked:
RestRequest getRequest = new RestRequest((Method)Enum.Parse(typeof(Method), method));
Upvotes: 1