NetCore.Apis.Consumer 1.0.5

Helper to consume rest API set up on .net core.

There is a newer version of this package available.
See the version list below for details.
Install-Package NetCore.Apis.Consumer -Version 1.0.5
dotnet add package NetCore.Apis.Consumer --version 1.0.5
<PackageReference Include="NetCore.Apis.Consumer" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetCore.Apis.Consumer --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
  1. Set up an ApiConsumer object and provide the base URL
 var consumer = new ApiConsumer("http://myApiUrl");
  1. Create a basic HTTP request with get, post, put or delete. Let's say the post returns an object of a class "User":
 var response = consumer.PostAsync<User>("api/myurl", obj); // generic type is optional. 
  1. The response object can be used to check the following
 HttpStatusCode statusCode = response.StatusCode;
 string text = response.TextResponse; // response also has an implicit operator to string
 HttpResponseMessage msg = response.Response;
 if (response.IsBadRequest) Dictionary<string, string[]> errors = response.Errors; // default format provided by .net core API
 if (response.IsSuccessful) User user = response; // or response.Data
  1. Set up an ApiConsumer object and provide the base URL
 var consumer = new ApiConsumer("http://myApiUrl");
  1. Create a basic HTTP request with get, post, put or delete. Let's say the post returns an object of a class "User":
 var response = consumer.PostAsync<User>("api/myurl", obj); // generic type is optional. 
  1. The response object can be used to check the following
 HttpStatusCode statusCode = response.StatusCode;
 string text = response.TextResponse; // response also has an implicit operator to string
 HttpResponseMessage msg = response.Response;
 if (response.IsBadRequest) Dictionary<string, string[]> errors = response.Errors; // default format provided by .net core API
 if (response.IsSuccessful) User user = response; // or response.Data

Release Notes

- error validations
     - default events

Version History

Version Downloads Last updated
1.2.0 77 2/13/2019
1.1.1 111 10/15/2018
1.1.0 110 9/6/2018
1.0.6 175 7/4/2018
1.0.5 181 7/1/2018
1.0.2 146 6/29/2018
1.0.1 170 6/28/2018
1.0.0 171 6/27/2018