Language

SlackApi.CallAsync(String, Object, String, CancellationToken) Method

Definition

Invokes a Slack Web API method asynchronously using the specified method name, options, and authentication token.

public System.Threading.Tasks.Task<Microsoft.Agents.Extensions.Slack.Api.SlackResponse> CallAsync(string method, object? options = default, string token = "", System.Threading.CancellationToken cancellationToken = default);
member this.CallAsync : string * obj * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Agents.Extensions.Slack.Api.SlackResponse>
Public Function CallAsync (method As String, Optional options As Object = Nothing, Optional token As String = "", Optional cancellationToken As CancellationToken = Nothing) As Task(Of SlackResponse)

Parameters

method
String

The name of the Slack API method to call. Cannot be null, empty, or whitespace.

options
Object

An object containing parameters to include in the API request body. May be null if no parameters are required.

token
String

The OAuth access token used to authenticate the request. If empty, the request may fail unless the API method allows unauthenticated access.

cancellationToken
CancellationToken

A cancellation token that can be used to cancel the operation.

Returns

A task that represents the asynchronous operation. The task result contains a SlackResponse object with the API response data. If the call fails, the SlackResponse will have Ok set to false and an error message.

Remarks

If the API call fails or an exception occurs, the returned SlackResponse will indicate failure and include the error message. This method does not throw exceptions for API errors; instead, errors are reported in the SlackResponse. This method uses a HTTP client named "SlackApi" created by the injected IHttpClientFactory.

Applies to