RetailMediaChannelTwitterConnector::extractErrorMessageFromWebResponse Method [AX 2012]

Looks for and extracts an error message from a web-response received from a Twitter's API call.

client server public static str extractErrorMessageFromWebResponse(RetailWebResponse _webResponse)

Run On

Called

Parameters

_webResponse
Type: RetailWebResponse Class
The RetailWebResponse object to extract the error message from.

Return Value

Type: str
The error message.

The following cases are implemented.

1) If the response has HTTP status code 200, it returns an empty string.

2) If the response's content type is JSON: 2.1) If the data could be parsed as JSON and there is a key with name 'error', it returns value of that key.

2.2) Otherwise it returns an empty string.

3) If the response contains 2 occurances of word 'html' (no matter the case), it returns an empty string.

4) Otherwise it returns the content data as is.

Show: