The project ‘RestApiWrapUtility’ (RESTful API Wrapper Utility) is an open source .NET C# utility which implements a RESTful API wrapper. The utility is created in order to be an intermediate layer between clients that want to communicate with a remote server in order to use its RESTful services.

Whenever a client wants to communicate with a remote RESTful server needs to create appropriate HTTP requests in a RESTful meaning. For this reason, the utility isolates the client from any kind of client – server communication and also hides the REST API design of the server. At the moment, the utility contains some RESTful calls only for demonstration issues. You may adapt the utility to support your API requests / responses. For example, you could adapt the utility for supporting Facebook or Twitter (such as Twilio .NET Helper Library)  or any other web application.

You should know that the request – response communication is implemented with RestSharp which means that you can have satisfactory support of HTTP for your calls. Also, the utility handles with Json.NET the responses either as strongly typed models or as dynamic C# objects. Whenever you want, you may set a timeout for your calls. Please, keep in mind that the utility logs useful information with Log4Net about any request / response communication.

Here is an example of how we can use the utility in a client :

ServerCallerParameters parameters = new ServerCallerParameters (
  "https://server.com:1634/", Canal.ANDROID
);

ServerCaller server = new ServerCaller(parameters);

string accessToken = server.OAuth.Login("password",
                                        "all",
                                        "p3dbi8YDFl0ukda1hnznQCGicBCHGf",
                                        "2bMVEP0DLm89Cl4PD-il4omys7EK6X",
                                        "stathis.chatzikyriakidis@gmail.com",
                                        "1-33AD1-L");

server.SetAccessToken(accessToken);

dynamic result = server.Event.UploadPicture(10,
                                            "Picture Name",
                                            "/9j/4AA...Base64....AABQ==");

In the above example, we create first the ServerCallerParameters object passing the base server URL where the remote server listens and the canal (channel) of the communication. After that, we create the server object itself. The next step is to login to the remote server in order to get a valid access token for using its services. At the end, as an example we upload a picture with name “Picture Name” and data in Base64 format in the event with id 10.

The utility is currently in a stable version and you can find its source code online here.