1

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:

  1. I created a developer edition account and a community owned by me.
  2. 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 an access_token and instance_url.
  3. 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 the subjectId to represent the community in the actual attempt to post my item.

  4. 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?

2

The subjectId refers to the Id of the object you are posting to. Look at subjectId parameter here.

This is for making a feed post to an account's feed or a user's feed for example. Changing the subjectId to just me should post to your feed in that community since you are already using that community's REST endpoint.

| improve this answer | |
  • 1
    I see that when I change the subjectId to "me" I can successfully post the message to the feed on my own profile within the community, but it doesn't show up in the "questions" section, which is where I really want it to go. I guess I don't know the distinction between those feeds in my community. I am using the Napili template, FWIW. – Chris Farmer Nov 29 '16 at 23:13
  • Also, when I eliminate subjectId from my request body json, I get an error saying that it's required, hence trying to use "me" instead. – Chris Farmer Nov 29 '16 at 23:14
  • Thanks for the lead... I realized that I had to add capabilities to my post body with questionAndAnswers and a topic, and it now gets displayed how I hoped it would. Still using "me" for the the subjectId. – Chris Farmer Nov 30 '16 at 5:35
  • Glad you got it working! Edited my answer. – citizen conn Nov 30 '16 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.