Skip to content

Instantly share code, notes, and snippets.

@michaelbramwell
Last active May 6, 2016 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelbramwell/5cf972b6f35cd3ae9982b8f5400609ab to your computer and use it in GitHub Desktop.
Save michaelbramwell/5cf972b6f35cd3ae9982b8f5400609ab to your computer and use it in GitHub Desktop.
Generic Request with RestRequest lib
public static IRestResponse<T> MakeRequest(string relativeUrl, Func<RestClient, RestRequest, IRestResponse<T>> clientFunc)
{
var client = new RestClient("https://someresource.com");
var request = new RestSharp.RestRequest(relativeUrl);
return clientFunc(client, request);
}
// example call
var request = MakeRequest("/api/whatever", (c, r) => c.Execute<SomeType>(r));
var deserializedSomeTypeData = request.Data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment