Http.GetAsync
method · Http · cAlgo.API
DesktopCLICloud
Performs a GET request to the specified URI asynchronously.
Environment behaviour
Cloud — not supported. No request is sent. The response, or the callback, has IsSuccessful false, StatusCode 403 and Body null. No exception is thrown.
Overloads
| Signature |
|---|
GetAsync(Uri uri, Action<HttpResponse> callback) |
GetAsync(string uri, Action<HttpResponse> callback) |
GetAsync(Uri uri, Action<HttpResponse> callback)
Performs a GET request to the specified URI asynchronously.
void GetAsync(Uri uri, Action<HttpResponse> callback)
api.Http.GetAsync(uri: Uri, callback: Callable[[HttpResponse], None]) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
uri | Uri | Uri | The URI that the GET request should be made to. |
callback | Action<HttpResponse> | Callable[[HttpResponse], None] | The method to be invoked when the request is being sent. |
Examples
var uri = new Uri("https://api.example.com/quotes/EURUSD");
Http.GetAsync(uri, response => Print("Status: {0} | Body: {1}", response.StatusCode, response.Body));
from System import Uri
uri = Uri("https://api.example.com/quotes/EURUSD")
api.Http.GetAsync(uri, lambda response: api.Print(f"Status: {response.StatusCode} | Body: {response.Body}"))
GetAsync(string uri, Action<HttpResponse> callback)
Performs a GET request to the specified URI asynchronously.
void GetAsync(string uri, Action<HttpResponse> callback)
api.Http.GetAsync(uri: str, callback: Callable[[HttpResponse], None]) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
uri | string | str | The string containing the URI that the GET request should be made to. |
callback | Action<HttpResponse> | Callable[[HttpResponse], None] | The method to be invoked when the request is being sent. |
Examples
Http.GetAsync("https://api.example.com/quotes/EURUSD", response =>
{
if (response.IsSuccessful)
Print(response.Body);
});
api.Http.GetAsync("https://api.example.com/quotes/EURUSD", lambda response: api.Print(response.Body) if response.IsSuccessful else None)