src/Stratis.FederatedSidechains.AdminDashboard/Rest/ApiRequester.cs
/// <summary>
/// Make a HTTP request with POST method
/// </summary>
/// <param name="endpoint">HTTP node endpoint</param>
/// <param name="path">URL</param>
/// <param name="body">Specify the body request</param>
/// <returns>An ApiResponse object</returns>
Make a HTTP request with POST method
Make a HTTP request with POST method
public static async Task<ApiResponse> PostRequestAsync(string endpoint, string path, object body)
        {
            var restClient = new RestClient(string.Concat(endpoint, path));
            var restRequest = new RestRequest(Method.POST);
            restRequest.AddHeader("Content-type", "application/json");
            restRequest.AddJsonBody(body);
            IRestResponse restResponse = await restClient.ExecuteTaskAsync(restRequest);
            return new ApiResponse
            {
                IsSuccess = restResponse.StatusCode.Equals(HttpStatusCode.OK),
                Content = JsonConvert.DeserializeObject(restResponse.Content)
            };
        }
public static async Task < ApiResponse > PostRequestAsync ( string endpoint , string path , object body ) { var restClient = new RestClient ( string . Concat ( endpoint , path ) ) ; var restRequest = new RestRequest ( Method . POST ) ; restRequest . AddHeader ( " " , " " ) ; restRequest . AddJsonBody ( body ) ; IRestResponse restResponse = await restClient . ExecuteTaskAsync ( restRequest ) ; return new ApiResponse { IsSuccess = restResponse . StatusCode . Equals ( HttpStatusCode . OK ) , Content = JsonConvert . DeserializeObject ( restResponse . Content ) } ; }
Make a HTTP request with POST method
Make a HTTP request with POST method
An ApiResponse object
An ApiResponse object
endpoint
string
HTTP node endpoint
HTTP node endpoint
path
string
None
body
object
Specify the body request
Specify the body request