Http.SendAsync
method · Http · cAlgo.API
DesktopCLICloud
Performs a request to the specified URI. The request method depends on the value of the request.Method property.
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.
Definition
void SendAsync(HttpRequest request, Action<HttpResponse> callback)
api.Http.SendAsync(request: HttpRequest, callback: Callable[[HttpResponse], None]) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
request | HttpRequest | HttpRequest | The HttpRequest object representing the request contents. |
callback | Action<HttpResponse> | Callable[[HttpResponse], None] | The method to be invoked when the request is being sent. |
Examples
var request = new HttpRequest(new Uri("https://api.example.com/signals"))
{
Method = HttpMethod.Post,
Body = "EURUSD buy"
};
Http.SendAsync(request, response => Print("Signal sent: {0}", response.IsSuccessful));
from System import Uri
request = HttpRequest(Uri("https://api.example.com/signals"))
request.Method = HttpMethod.Post
request.Body = "EURUSD buy"
api.Http.SendAsync(request, lambda response: api.Print(f"Signal sent: {response.IsSuccessful}"))
See also