1

I have been reading up on the Chatter API. I am trying to use the Chatter API to search through a users Chatter items: Feed, People, Groups, Files.

After OAuth authentication, I can successfully do a GET to the following to get Feed, People, and Group results for a user:

/services/data/v34.0/chatter/feed-elements?q=Hello
/services/data/v34.0/chatter/users?q=John
/services/data/v34.0/chatter/groups?q=Sales

However, I cannot seem to figure out a way to search through the Files in the Chatter account. The following does not work:

/services/data/v34.0/chatter/files?q=test_plan

I have read through the documentation (https://resources.docs.salesforce.com/196/latest/en-us/sfdc/pdf/salesforce_chatter_rest_api.pdf) but could not figure how to search for files. What am I missing here?

1

You can search through files that a user owns with a GET request to the User Files, General endpoint:

/chatter/users/<userId>/files?q=hello

But for a general file search, you'll need to do a SOQL query on ContentVersion or ContentDocument as described in the other answer.

  • Brilliant, worked just fine! Thanks. On a related note, how can I limit the fields being returned, sort of like how it's possible with SOSL? – rc1 Jul 7 '15 at 0:51
  • Do you want to a) search only on certain fields, or b) include only certain fields in the response? Option a) isn't possible with the REST endpoint. For Option b), you can use either filter groups or inclusion/exclusion filters: developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/… – alouie Jul 7 '15 at 6:52
  • I was trying to do Option b, and the resource you pointed me to is just right. Thanks yet again. – rc1 Jul 11 '15 at 1:35
0

You may want to query ContentVersion object for chatter file names. Looks to me all services are expecting some id (file or folder id).

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.