function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Akshay Mourya 6Akshay Mourya 6 

Feeditem Post

Hi All,
I want to add the feed post using the rest API. I am using python for the same. But while hiting to the rest api its giving me request not found error.
Could you please let me know what is excat issue? Is there any issue with my request body or url/version?

I am attaching the request and url below .

data=     {
       "body":{
          "text":"Test Example"
       },
       "capabilities":{
          "Content":
                {"contentDocumentId": "0692y000002KKyhAAG"}
     
       },
    "type":"ContentPost",
       "feedElementType":"FeedItem",
    "parent":"5002y000005rBTWAA2"
    }




response = requests.post('https://%s.salesforce.com/services/data/v46.0/sobjects/chatter/feed-elements' % instance,
    headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer %s' % sessionId },
    data = json.dumps(data)
)

print (response.text)

Error Message - {"errorCode":"NOT_FOUND","message":"The requested resource does not exist"}

Thanks
SwethaSwetha (Salesforce Developers) 
HI Akshay,
Looks like the resource URL is not correct. 

Per the documentation https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_feed_element.htm the supported URLs are
/chatter/feed-elements/feedElementId
and
/connect/communities/0DB6F000000fzBMWAY/chatter/feed-elements/feedElementId
Also, the required parameters mentioned in the documentation needs to be passed with the URL.

Note that only the HTTP methods:GET, DELETE, PATCH are supported. POST is not supported.

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you