Please be aware of 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 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, all security, field level sharing, and visibility is controlled
by the context user. For example, if a 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 cannot 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 is not available immediately. For testing,
this means that 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 cannot be used in Apex SOAP Web services indicated with the keyword webservice.