Work with Response Metadata

The following are Apex classes to work with response metadata for errors and warnings. Slack returns response metadata as part of the Web API calls, which are helpful for debugging or error handling. Detailed errors and warnings are returned in the messages field in the response metadata.

ResponseMetadata Class 

Represents response metadata from a Slack Web API call.

Usage 

When receiving a response from Slack’s API call, use getResponseMetadata().getMessages() to retrieve any error messages. This example shows how to retrieve the error messages from Slack.ChatPostMessageResponse.

1Slack.ChatPostMessageRequest req = new Slack.ChatPostMessageRequest.builder()
2    .channel((String) this.parameters.get('channelId'))
3    .text('Details for record id' + recordId)
4    .viewReference(viewReference)
5    .build();
6
7Slack.ChatPostMessageResponse response = userClient.ChatPostMessage(req);
8if (response.getError() != null) {
9    System.debug(response.getResponseMetadata().getMessages());
10}

ResponseMetadata Methods 

The following are methods for ResponseMetadata.

getMessages() 

Signature

1public List<String> getMessages()

Return Value

Type: List<String>

getNextCursor() 

Responses include the next_cursor value to navigate through additional results. See Paginating through collections.

Signature

1public String getNextCursor()

Return Value

Type: String

getResponseMetadata() 

Signature

1public Slack.ResponseMetadata getResponseMetadata()

Return Value

Type: Slack.ResponseMetadata

getWarnings() 

Signature

1public List<String> getWarnings()

Return Value

Type: List<String>

setMessages(messages) 

Signature

1public void setMessages(List<String> messages)

Parameters

messages

Type: List<String>

Return Value

Type: void

setNextCursor(nextCursor) 

Signature

1public void setNextCursor(String nextCursor)

Parameters

messages

Type: String

Return Value

Type: void

ssetResponseMetadata(responseMetadata) 

Signature

1public void setResponseMetadata(Slack.ResponseMetadata responseMetadata)

Parameters

responseMetadata

Type: Slack.ResponseMetadata

Return Value

Type: void

setWarnings(warnings) 

Signature

1public void setWarnings(List<String> warnings)

Parameters

warnings

Type: List<String>

Return Value

Type: void

ErrorResponseMetadata Class 

Represents response metadata for an error.

ErrorResponseMetadata Methods 

The following are methods for ErrorResponseMetadata.

getMessages() 

Signature

1public List<String> getMessages()

Return Value

Type: List<String>

setMessages(messages) 

Signature

1public void setMessages(List<String> messages)

Parameters

messages

Type: List<String>

Return Value

Type: void

WarningResponseMetadata Class 

Represents response metadata for a warning.

WarningResponseMetadata Methods 

The following are methods for WarningResponseMetadata.

getWarnings() 

Signature

1public List<String> getWarnings()

Return Value

Type: List<String>

setWarnings(warnings) 

1public void setWarnings(List<String> warnings)

Parameters

warnings

Type: List<String>

Return Value

Type: void

Beta Feature

This feature is not generally available. It is not part of your purchased Services. This feature is subject to change, may be discontinued with no notice at any time in SFDC’s sole discretion, and SFDC may never make this feature generally available. Make your purchase decisions only on the basis of generally available products and features. This feature is made available on an AS IS basis and use of this feature is at your sole risk.