An open API service indexing awesome lists of open source software.

https://github.com/logikoz/log.restsharp.dependencies

Base codes for personal projects.
https://github.com/logikoz/log.restsharp.dependencies

dotnet-standard rest unit-testing

Last synced: 22 days ago
JSON representation

Base codes for personal projects.

Awesome Lists containing this project

README

        

# Simple implementation for RestSharp lib
Base REST request service for personal projects, writen with .net standard 2.1

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

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

With parameters:
```csharp
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:
```csharp
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.