https://github.com/anuviswan/resthelper
RestHelper is a sleek and simple Wrapper library for providing simple access to Rest API, by hiding away the complexities of HTTPClient Class.It is particularly designed to work along with Xamarin PCL Projects.
https://github.com/anuviswan/resthelper
Last synced: about 1 year ago
JSON representation
RestHelper is a sleek and simple Wrapper library for providing simple access to Rest API, by hiding away the complexities of HTTPClient Class.It is particularly designed to work along with Xamarin PCL Projects.
- Host: GitHub
- URL: https://github.com/anuviswan/resthelper
- Owner: anuviswan
- Created: 2016-12-20T14:07:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-10T13:52:18.000Z (about 8 years ago)
- Last Synced: 2025-03-14T15:04:53.917Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 34.7 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RestHelper
--------------
RestHelper is a sleek and simple Wrapper library for providing simple access to Rest API, by hiding away the complexities of HTTPClient Class.It is particularly designed to work along with Xamarin PCL Projects. The Project is an open-source solution created by EcSolvo Technologies and maintained by contribution from Open-Source Community.
Nuget Package : https://www.nuget.org/packages/EcSolvo.RestHelper/
The following section outlines how to use EcSolvo.RestHelper Libraries.
RestHelper Constructor and ExecuteAsync
-----------------------------------------
The RestHelper Constructor and ExecuteAsync Method is the heart of RestHelper Library. It is build on 'Pit of Success' philosophy, removing erronous steps by the consuming Developer.
The RestHelper Constructor takes a single Parameter, which is the base address of your API.The ExecuteAsync is an Asynchronous Method which take in two Parameters,
a) HTTP Verb (GET,POST)
b) Resource (URL to the exact API Resource)
For GET Request
----------------
For Handling URI Parameters, the EcSolvo.RestHelper Library exposes a method called 'AddURLParameters', which helps to add parameters to the QueryString dictionary.
private string _BaseAddress = "http://localhost:8888/";
var resourceURL = "api/user/SingleParamStringResponse";
var restHelper = new EcSolvo.RestHelper(_BaseAddress);
string ParameterKey = "VariableStr";
string ParameterValue = "DummyString";
restHelper.AddURLParameters(ParameterKey, ParameterValue);
var result = await restHelper.ExecuteAsync(HttpMethod.Get, resourceURL);
The library works even if the parameter passed is a Complex Parameter (Controller uses FromUri Attribute).
For POST Request
-----------------
For Handling OnBody Parameter in POST Request, the library exposes a method called 'AssignMessageBodyParameter'.
restHelper.AssignMessageBodyParameter(Parameter);
var result = await restHelper.ExecuteAsync(HttpMethod.Post, resourceURL);
If the POST Request have additional URI Parameters, it can use the 'AddURLParameters' Method to add it to the dictionary.