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.
- Host: GitHub
- URL: https://github.com/logikoz/log.restsharp.dependencies
- Owner: Logikoz
- Created: 2020-03-13T04:47:59.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-06T02:39:45.000Z (over 3 years ago)
- Last Synced: 2024-06-21T21:03:25.670Z (10 months ago)
- Topics: dotnet-standard, rest, unit-testing
- Language: C#
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple implementation for RestSharp lib
Base REST request service for personal projects, writen with .net standard 2.1GET 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.