0% found this document useful (0 votes)
23 views

Chatter REST API Cheatsheet

The Chatter REST API provides access to Chatter feeds and social data through resources that return JSON or XML data. It allows posting to feeds, commenting, liking, and following other users and records. Authentication uses OAuth 2.0 and resources are accessed by specifying the base URI, API version, and specific resource in the URL. The API supports pagination through nextPageUrl values when result sets span multiple pages.

Uploaded by

Bushera Hilal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Chatter REST API Cheatsheet

The Chatter REST API provides access to Chatter feeds and social data through resources that return JSON or XML data. It allows posting to feeds, commenting, liking, and following other users and records. Authentication uses OAuth 2.0 and resources are accessed by specifying the base URI, API version, and specific resource in the URL. The API supports pagination through nextPageUrl values when result sets span multiple pages.

Uploaded by

Bushera Hilal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Integration Chatter REST API Cheat Sheet

Overview Add Comments


The Chatter REST API provides access to Chatter feeds and social data such as users,
To add a comment to a feed item, use the feed items resource, specify the feed item ID,
groups, and followers. It returns data in JSON or XML format.
and pass the comment in a text parameter:

Construct the URL /chatter/feed-items/0D5D0000000DaSbKAK/comments?text=New+post

To access the Chatter REST API resources, specify a base URI for your company, version
information, and the resource. For example, if the base URI is this: Message Segments
https://na1.salesforce.com
And the version information is this: Feed item bodies and comment bodies are made up of an array of rich text elements called
/services/data/v29.0 "message segments." There are several types of message segments: text, hashtag, link,
And you’re using the following resource: mention, and so on.
/chatter/feeds/news/me/feed-items
To render a feed item or a comment, render the array of message segments in order. Format
Put together, the full URL to the resource is: message segments according to their type. For example, for a mention segment, you could
https://na1.salesforce.com/services/data/v29.0/chatter/feeds/ prefix the mention with an "@" symbol and make the user name a link to the user's profile.
news/me/feed-items
All message segments have a text property. Use the text property as the default case
Authentication when a client doesn't recognize a message segment type.

Chatter REST API uses OAuth 2.0 for authentication. The return from a successful
authentication includes an access token, which can be used for subsequent calls to the Feeds Resources
Chatter REST API resources by embedding it in an Authorization header, for example:
Authorization: Oauth <token>
There are many types of feeds, such as news, user profile and record.
Salesforce supports the Web server and user-agent OAuth flows.
To access most feeds, use the alias me or a user ID, such as 005D0000001GLowIAN.

Post a Feed Item /chatter/feeds/files/me


/chatter/feeds/groups/me
To update the status of the logged-in user, use the news feed or the record feed resources. /chatter/feeds/user-profile/005D0000001GLowIAN
To update the status of another user, use the user profile feed resource.
All feeds have a /feed-items resource that returns the feed items for that feed. For example, to
This example posts a feed item to the logged-in user's feed using the news feed resource: return the feed items for the current user’s news feed, make a GET request to the following resource:
/chatter/feeds/news/me/feed-items?text=New+post
/chatter/feeds/news/me/feed-items
This example posts a feed item to another user's feed using the user profile feed resource:
To get feed items from all groups the logged-in user owns or is a member of, use the
/chatter/feeds/user-profile/005D0000001GLowIAN/feed-
groups feed resource:
tems?text=New+post
/chatter/feeds/groups/me/feed-items
Like a Feed Item
To get feed items from a specific group, use the record feed resource with the group ID:
To like a feed item, make a POST request to the /chatter/feed-items resource and /chatter/feeds/record/0F9D00000004CD5KAM/feed-items
specify the feed item ID:

/chatter/feed-items/0D5D0000000DaZBKA0/likes Groups
Follow Records These are some of the Chatter REST API resources for working with groups:

Use the users resource to follow a specific record. A record can be any object in Salesforce, To get a list of all groups in an organization, make a GET request to this resource:
such as a custom record, a file, a user, and so on.
/chatter/groups
To follow a record, use POST with the subjectId request parameter. This example
follows a user: To get information about a specific group use this resource with a group ID:

/chatter/users/me/following?subjectId=005D0000001GpHp /chatter/groups/0F9D000000006bOKAQ

Unfollow Records To add a member to a group, use the /groups resource and POST with the group ID, the
userID request parameter, and the specified user ID.
Use the subscriptions resource to unfollow a record. You must use the subscription ID with
/chatter/groups/0F9D000000006bOKAQ/members?userId=005D0000001GLowIAB
the subscriptions resource. To get subscription IDs, use the following resource and specify a
user ID:
To post to a group, POST to the /feeds/record resource and specify the group ID, and the
/chatter/users/005D0000001GpHp/following text request parameter. For example:

To unfollow a record, make a DELETE request to this resource and specify the /chatter/feeds/record/0F9D000000006bO/feed-items
subscription ID: ?text=Has+everyone+seen+the+latest+building+proposal?
/chatter/subscriptions/0E8D00000001JkFKAU

http://developer.salesforce.com
Pagination Resources (continued)
Feeds, lists of groups or records a user is following, and other resources may return more
items than can be contained in a single page. The response for these collections contains Resource Description
a currentPageUrl and a nextPageUrl property. The currentPageUrl contains a
URL that points to the current page of items, while the nextPageUrl contains the URL /chatter/feeds/files A feed containing all the feed items that contain files
for the next page of items. posted by people or groups that the logged-in user follows.

The following is an example return from a news feed: /chatter/feeds/filter The filter feed is the news feed filtered to contain feed
items whose parent is a specified object type.
{
"currentPageUrl": "/services/data/v25.0/chatter/feeds/
news/005x0000001j2OwAAI/feed-items", /chatter/feeds/groups All feed items from all groups the logged-in user either
. . . owns or is a member of.
"nextPageUrl": "/services/data/v25.0/chatter/feeds/
news/005x0000001j2OwAAI/feed-items?page=2013-01-25T00%3A35%3A01Z
/chatter/feeds/news All feed items from all groups the logged-in user
%2C0D5D0000000JnAaKAK"
either owns or is a member of, as well as from all files,
}
records, and users the logged-in user follows. Use this
resource to get information about the feed items and to
The second page of items contains a new value for nextPageUrl. To page through
post feed items.
the feed items, use the URL from each subsequent page. There are no more pages when
nextPageUrl is null.
/chatter/feeds/people All feed items posted by all of the people the logged-in
Post a Feed Item with @mention user follows.

To post a feed item that @mentions a user, use a request body that contains a mention /chatter/feeds/record The feed of the specified record, which could be a
message segment. group, person, object, file and so on. You can post a
feed item to this feed. To post a feed item to a specific
Post the request body to the news feed, record feed, or user profile feed, for example: group, use this feed.
/chatter/feeds/user-profile/{userId}/feed-items
/chatter/feeds/to Feed of all @mentions of the logged-in user and posts
{ "body" : others make to the logged-in user's feed.
{
"messageSegments" : [ /chatter/feeds/user- Contains feed items created when a user changes records that
{ profile can be tracked in a feed, feed items whose parent is the user,
"type": "mention", and feed items that @mention the user. This feed is different
than the news feed, which returns more feed items. To post a
"id" : "005D0000001GpHp" feed item to a user's profile, use this feed.
},
{ /chatter/files Information about the specified file, including content,
"type": "text", rendered version, and sharing.
"text" : " Did you see the new plans?"
} /chatter/groups Information about groups, such as the group's members,
] photo, and the groups the current user is following.
} Use to add members to a group and change the group
} photo.This resource is not a feed. To get the feed for a
specific group, use the record feed resource: /chatter/
feeds/record/{groupId}/feed-items.
Resources
/chatter/likes Get information about a like or delete a like.
These are some of the Chatter REST API resources:

Resource Description /chatter/records Information about the specified record. This resource
is not a feed. To access a record feed, use the
/chatter/comments Get information about a comment, delete a comment, /chatter/feeds/record resource.
and like a comment.
/chatter/subscriptions Information about the specified subscription.
/chatter/feed-items Information about feed items. Access, search, delete, Also used to delete a subscription, for example, to
bookmark, and like feed items. Access and post unfollow a record.
comments. Access and vote in polls. Access, add, and
remove topics. /chatter/users Information about the user, such as who is following
the user, user messages, and recommendations.
/chatter/feeds A list of all of the feeds the logged-in user is able to view.
/connect/organization Information about the logged-in user’s organization
/chatter/feeds/bookmarks Feed items saved as bookmarks by the logged-in user. and settings.

/chatter/feeds/company All feed items and comments from an entire company. /connect/topics List of topics for the organization, list of suggested
topics for a specified string of text or feed item, list of
trending topics for the organization, information about
a specified topic, information about the files posted
/chatter/feeds/favorites A feed containing favorites saved by the logged-in recently to a specified topic, information about the
user. Favorites are feed searches, list views, and topics groups recently contributing to a specified topic, and
that the logged-in user has added as a Chatter favorite. list of topics related to a specified topic.

For other cheatsheets: http://developer.force.com/cheatsheets 11182013

You might also like