I have the following code to get a Chatter Feed of a Case:
ConnectApi.FeedElementPage fep = ConnectApi.ChatterFeeds.getFeedElementsFromFeed(Network.getNetworkId(), ConnectApi.FeedType.Record, caseId, nextPageToken, RECENT_COMMENT_COUNT, null);
And everything works fine, except for the case when Knowledge Article with Data Category is attached to a Case using Knowledge component (on the screenshot) and the code mentioned above is executed by the user without access to this Data Category.
I get the following errors:
System.TypeException: Invalid conversion from runtime type ConnectApi.FeedItem to ConnectApi.FeedElementPage
System.TypeException: Invalid conversion from runtime type ConnectApi.EnhancedLinkCapability to ConnectApi.FeedElementCapabilities
I wanted to output text that this user does not have access to the article, but due to an error I can't do anything. Any ideas on how to fix this?