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 MouryaAkshay Mourya 

Feed attachment api

Hi All,
I want to post a feed with attachment using rest api but its giving me resource not found error. 
Please find the below code.
data= {
       "body":{
          "messageSegments":[
             {
                "type":"Text",
                "text":"Please take a look at these files."
             }
          ]
       },
       "attachment":"content",
       "capabilities":{
          "files":{
             "items": [
                {"id": "00P2y000006yGY8EAM"}    
             ]
          }
       },
       "subjectId":"5002y000006UlPKAA0",
       "feedElementType":"FeedItem",
    "type":"ContentPost"
    }



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)
)

Can you please let me know what is the issue?

Thanks
AnudeepAnudeep (Salesforce Developers) 
Can you try with a simple example and confirm if it returns results? 
 
{
   "body":{
      "messageSegments":[
         {
            "type":"Text",
            "text":"Please take a look at these files."
         }
      ]
   },
   "capabilities":{
      "files":{
         "items": [
            {"id": "069D00000001IOh"},
            {"id": "069D00000002IOg"}
         ]
      }
   },
   "subjectId":"me",
   "feedElementType":"FeedItem"
}