Skip to content

CallApi.cs

Avrigeanu Laurian edited this page Apr 17, 2023 · 1 revision

CallApi(apiUrl: string) : string

Parameters

  • apiUrl (string): The URL of the API to call.

Returns

  • A string containing the response body of the API call if the call was successful.

Remarks

  • This method uses the HttpClient class to call an API at the specified URL.
  • If the API call is successful, the method returns the response body as a string.
  • If the API call is not successful, the method throws an HttpRequestException with a message indicating the status code of the failed request.
Clone this wiki locally