APIRequest - A Powerful Package for API Requests APIRequest is a NuGet package designed to simplify sending and receiving HTTP/HTTPS requests to web APIs. This package helps developers easily access external resources, send data, and handle responses with minimal code.
Features: Support for Multiple HTTP Methods: Including GET, POST, PUT, DELETE, and more. Simple Management of Headers and Parameters: Allows adding custom headers and parameters to requests. Easy Serialization and Deserialization: Full support for JSON using Newtonsoft.Json for data management. Support for Authentication: Ability to use JWT tokens and other authentication methods. Error Handling: Advanced features for handling errors and response statuses.
To install the APIRequest.net package, simply run the following command in the NuGet Package Manager console:
"dotnet add package ApiRequest.Net --version 1.1.0"
builder.Services.AddTransient();
After that, You must add this dependency in the constructor of the class you want to use this package. For example, I took the user altogether:
private readonly CallApi _callApiServies; public HomeController(CallApi callApiServies) { _callApiServies = callApiServies ?? throw new ArgumentException(nameof(callApiServies)); }
or you can just create instance of CallApi Class
var data = new { Username = user.UserName, Email = user.Email, Password = user.Password, RePassword = user.RePassword };
var response = await _callApiServies.SendPostRequest<List>("your_api_URL", data = defult null, "your_JWT_TOken" = defult null);