RestWrapper 1.0.8

A simple C# wrapper for making REST API requests (RESTful HTTP and HTTPS)

Install-Package RestWrapper -Version 1.0.8
dotnet add package RestWrapper --version 1.0.8
paket add RestWrapper --version 1.0.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

RestWrapper

[![][nuget-img]][nuget] [nuget]: https://www.nuget.org/packages/RestWrapper/ [nuget-img]: https://badge.fury.io/nu/Object.svg A simple C# class library to help simplify RESTful HTTP requests and responses.

Test App

A test project is included which will help you exercise the class library.

Available APIs

Two static methods exist: SendRequest and SendRequestSafe. The differences are as follows:

  • SendRequest will throw any exception encountered to the caller

RestWrapper

A simple C# class library to help simplify RESTful HTTP requests and responses.

Test App

A test project is included which will help you exercise the class library.

Available APIs

Two static methods exist: SendRequest and SendRequestSafe. The differences are as follows:

  • SendRequest will throw any exception encountered to the caller
  • SendRequestSafe will take any WebException and create a RestResponse object from it. Other exceptions are thrown to the caller

Example

using RestWrapper;

//
// Simple GET with No Credentials
//
RestResponse resp = RestRequest.SendRequest(
	"http://www.github.com/",	// URL
	null, 						// content-type
	"GET",						// verb/method
	null, null, false, 			// user, password, encode
	null, 						// headers
	null);						// byte array data

//
// Enumerate response
//
Console.WriteLine(
	"Received " + resp.StatusCode + " (" + resp.ContentLength + " bytes) " +
	"with data: " + Encoding.UTF8.GetString(resp.Data));

//
// POST with Headers and Credentials
//
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("x-custom-header", "my-custom-value");
byte[] data = Encoding.UTF8.GetBytes("some-field=some-value&hello=world");

RestResponse resp = RestRequest.SendRequest(
	"https://my.server.com/form",			// URL
	"application/x-www-form-urlencoded",	// content-type
	"POST",									// verb/method
	"my-username", "my-password", true, 	// user, password, encode
	headers,								// headers
	data);									// byte array data

//
// Enumerate response
//
Console.WriteLine(resp.ToString());		// Easy peasy

Release Notes

Variable casing, conversion methods, suppor for OPTIONS

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
1.0.8 (current version) 62 8/11/2017
1.0.7 62 6/23/2017
1.0.6 70 5/14/2017
1.0.5 124 10/11/2016
1.0.4 77 10/7/2016