SG.RestClient
1.0.0
dotnet add package SG.RestClient --version 1.0.0
NuGet\Install-Package SG.RestClient -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SG.RestClient" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SG.RestClient --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SG.RestClient, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SG.RestClient as a Cake Addin #addin nuget:?package=SG.RestClient&version=1.0.0 // Install SG.RestClient as a Cake Tool #tool nuget:?package=SG.RestClient&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SG.RestClient
C# Rest Client to perform REST communication in your .Net Apps
Import Reference
using SG.RestClient.Constant;
using SG.RestClient.Interface;
using SG.RestClient.Model;
RestClient Config:
RestConfig RestCfg = new RestConfig();
RestCfg.EnableLogOutput = true;
RestCfg.ProxySetting = Proxy.SystemDefault;
Description:
- EnableLogOutput : Provide log output when REST communication completed.
- ProxySetting : An indicator to determine proxy setting for your REST communication (SystemDefault, Custom, Disabled)
- Proxy : Define your proxy address here if you use custom proxy.
- BaseAddress : Base URL for your REST Service.
HttpConfig
HttpConfig config = new HttpConfig();
config.ContentType = MediaType.Json;
config.Method = HttpMethod.GET;
config.Headers = Headers;
Description:
- Method : POST, GET, etc
- ContentType : application/json, etc
- Headers : Custom headers
- TimeOut : Request timeout
**Example 😗*
RestClient RestClient = new RestClient(RestCfg);
GET
IRestClientResponse Result = await RestClient.GetAsync("http://localhost:88/RESTService/api/student", config);
IRestClientResponse Result = RestClient.GetAsync("http://localhost:88/RESTService/api/student", config).GetAwaiter().GetResult();
Result
bool IsSuccess = Result.Success;
string StrResult = Result.Response;
string LogOutput = Result.LogOutput;
Exception Exception = Result.Exception;
LogOutput will be returned if RestConfig (EnableLogOutput) set to true
GET (with Return Type)
IRestClientResponse<Student> Result = await RestClient.GetAsync<Student>("http://localhost:88/RESTService/api/student", config)
IRestClientResponse<Student> Result = RestClient.GetAsync<Student>("http://localhost:88/RESTService/api/student", config).GetAwaiter().GetResult();
Result
bool IsSuccess = Result.Success;
Student StrResult = Result.Response;
string LogOutput = Result.LogOutput;
Exception Exception = Result.Exception;
POST
There are 4 method that provided for verb-type POST:
Task<IRestClientResponse<TResult>> PostAsync<TResult, TRequest>(string Path, TRequest Request, HttpConfig HttpConfig = null)
Input
- URL/Path
- Object Request (TRequest)
- HttpConfig
Output
- Object Response (TResult)
Task<IRestClientResponse<TResult>> PostAsync<TResult>(string Path, string StrJsonRequest, HttpConfig HttpConfig = null)
Input
- URL/Path
- String Request
- HttpConfig
Output
- Object Response (TResult)
Task<IRestClientResponse> PostAsync<TRequest>(string Path, TRequest Request, HttpConfig HttpConfig = null)
Input
- URL/Path
- Object Request (TRequest)
- HttpConfig
Output
- String Response
Task<IRestClientResponse> PostAsync(string Path, string StrJsonRequest, HttpConfig HttpConfig = null)
Input
- URL/Path
- String Request
- HttpConfig
Output
- String Response
Example (POST)
POST Data
Student Student = new Student();
Student.StudentName = "Gunadi";
Student.StudentGrade = "IIA";
Student.StudentAddress = "Carl Street";
1
IRestClientResponse<Student> Result = await RestClient.PostAsync<Student>("http://localhost:88/RESTService/api/student", JsonConvert.SerializeObject(Student), config);
2
IRestClientResponse<Student> Result = await RestClient.PostAsync<Student, Student>("http://localhost:88/RESTService/api/student", Student, config);
3
IRestClientResponse Result = await RestClient.PostAsync<Student>("http://localhost:88/RESTService/api/student", Student, config)
4
IRestClientResponse Result = await RestClient.PostAsync("http://localhost:88/RESTService/api/student", JsonConvert.SerializeObject(Student), config);
Result
bool IsSuccess = Result.Success;
Student StrResult = Result.Response;
string LogOutput = Result.LogOutput;
Exception Exception = Result.Exception;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- Newtonsoft.Json (>= 12.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 594 | 10/4/2019 |
Version 1.0.0