Newer Version Available
Differences Between ConnectApi Classes and Other Apex Classes
Note these additional differences between ConnectApi classes and other Apex classes.
- System mode and context user
- Chatter in Apex methods don’t run in system mode, they run in the context of the current user (also called the context user). The methods have access to whatever the current user has access to. Chatter in Apex does not support the runAs system method. When a method takes a subjectId argument, often that subject must be the context user. In these cases, you can use the string me to specify the context user instead of an ID.
- with sharing and without sharing
- Chatter in Apex ignores the with sharing and without sharing keywords. Instead, the context user controls all security, field level sharing, and visibility. For example, if the context user is a member of a private group, ConnectApi classes can post to that group. If the context user is not a member of a private group, the code can’t see the feed items for that group and can’t post to the group.
- Asynchronous operations
- Some Chatter in Apex operations are asynchronous, that is, they don’t occur immediately. For example, if your code adds a feed item for a user, it is not immediately available in the news feed. Another example: when you add a photo, it’s not available immediately. For testing, if you add a photo, you can’t retrieve it immediately.
- No XML Support in Apex REST
- Apex REST does not support XML serialization and deserialization of Chatter in Apex objects. Apex REST does support JSON serialization and deserialization of Chatter in Apex objects.
- Empty log entries
- Information about Chatter in Apex objects doesn’t appear in VARIABLE_ASSIGNMENT log events.
- No Apex SOAP Web services support
- Chatter in Apex objects can’t be used in Apex SOAP Web services indicated with the keyword webservice.