Skip to content

Logikoz/Log.RestSharp.Dependencies

Repository files navigation

Simple implementation for RestSharp lib

Base REST request service for personal projects, writen with .net standard 2.1

GET samples:

var response = await new RequestService()
{
  Method = Method.GET,
  URL = "https://logikoz.net",
  URN = "Tests"
}.ExecuteTaskAsync();

With jwt authorization header:

var response = await new RequestService()
{
  Method = Method.GET,
  URL = "https://logikoz.net",
  URN = "Tests",
  Authenticator = new JwtAuthenticator("123") // result: Bearer 123
}.ExecuteTaskAsync();

With parameters:

var request = new RequestService()
{
  Method = Method.GET,
  URL = "https://logikoz.net",
  URN = "Tests",
};

request.Parameters.Add("param1", "123");
request.Parameters.Add("param2", "123");
request.Parameters.Add("param3", "123");

IRestResponse response = await request.ExecuteTaskAsync();

POST samples:

var response = await new RequestService()
{
  Method = Method.POST,
  URL = "https://logikoz.net",
  URN = "Tests/add",
  Body = obj // C# object, no need to serialize.
}.ExecuteTaskAsync();

For PUT, Delete, Options... methods, follow the same principle as the examples cited above.

About

Base codes for personal projects.

Topics

Resources

Stars

Watchers

Forks

Languages