My overall goal is to post a simple feed item to a community using the REST API. I am having some trouble with either the process or the configuration of my community, or both. Any pointers would be appreciated!
Here's what I am trying now:
- I created a developer edition account and a community owned by me.
- I first authenticate via the
https://login.salesforce.com/services/oauth2/token
endpoint. I think this step is fine, since I get back a json object with anaccess_token
andinstance_url
. I try to get a list of my communities from
https://mycustomurl-developer-edition.na35.force.com/community/services/data/v38.0/connect/communities/
. I get back json like below.{ "communities": [ { "allowChatterAccessWithoutLogin": false, "allowMembersToFlag": false, "description": null, "id": "0DB410000008PYdGAN", "invitationsEnabled": false, "knowledgeableEnabled": false, "loginUrl": "https://mycustomurl-developer-edition.na35.force.com/community/s/login", "name": "Chris F. Test Community", "nicknameDisplayEnabled": false, "privateMessagesEnabled": false, "reputationEnabled": false, "sendWelcomeEmail": true, "siteUrl": "https://mycustomurl-developer-edition.na35.force.com/community", "status": "Live", "url": "/services/data/v38.0/connect/communities/0DB410000008PYdGAN", "urlPathPrefix": "community" } ], "total": 1 }
I think I should use this
id
property as thesubjectId
to represent the community in the actual attempt to post my item.I then tried to post a feed item to this community using the "Post a Feed Item" docs. I make an http post to
https://mycustomurl-developer-edition.na35.force.com/community/services/data/v38.0/chatter/feed-elements?feedElementType=FeedItem&subjectId=0DB410000008PYdGAN&text=Post+from+rest
. I set the authorization header, and I include the following as the body of the request:{ "body" : { "messageSegments" : [ { "type" : "Text", "text" : "This is the content of my post." } ] }, "feedElementType" : "FeedItem", "subjectId" : "0DB410000008PYdGAN" }
I get back an error message that looks like this:
[
{
"errorCode": "INVALID_ID_FIELD",
"message": "The object at parameter 'subjectId' value '0DB410000008PYdGAN' does not support Chatter."
}
]
I am assuming that this subjectId
is the correct one to use, based on the docs for the Feed Item. It's the id that is associated with my community, at least. If my community doesn't currently support Chatter, how can I enable that in my community? Is there anything else I'm doing that is obviously wrong?