An application I use has a REST API. In C#, is there an example of writing a wrapper for this to invoke the API’s functions?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Writing your own wrapper for REST usage is not terribly difficult. Any client would be making use of the HttpWebRequest and HttpWebResponse objects to execute GET requests and retrieve the results. (There are other objects in the .Net Framework that can be used, but I’ve found these to be the most useful.)
This is actually the simple part. How you interpret the results (read as a string, parse the xml response, deserialize to strongly-typed objects, etc.) are more involved in the decision process. My advice to this end: keep it as simple as you can, but make your wrapper self-contained. Don’t require your calling logic to have to know anything about sending the request or interpreting the response.