You need to sign in to do that
Don't have an account?
Problem about Retrieve the Chatter News Feed
Hi,
I have create a java project to do some operates about Chatter.
When I want to retrieve the news feed , I meet a problem.
This is my method:
private static void displayNewsFeed() throws Exception { QueryResult queryResults = connection .query("SELECT Id, Type, CreatedDate, CreatedBy.name, Body " + "FROM NewsFeed WHERE Type= 'UserStatus' " + "ORDER BY CreatedDate DESC, ID DESC LIMIT 10"); System.out.println(queryResults.getSize()); if (queryResults.getSize() > 0) { for (SObject s : queryResults.getRecords()) { System.out.println(s.getChild("NewsFeed").getField("Body")); } } }
When I execute this method there has a Exception:
Exception in thread "main" [InvalidFieldFault [ApiQueryFault [ApiFault exceptionCode='INVALID_FIELD'
exceptionMessage='
CreatedDate, CreatedBy.name, Body FROM NewsFeed WHERE Type= 'UserStatus'
^
ERROR at Row:1:Column:47
No such column 'Body' on entity 'NewsFeed'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.'
]
row='1'
column='47'
]
]
That's the exception from my eclipse console. It said the 'Body' is not in "NewsFeed".
I have downloaded the Enterprise WSDL from salesforce.com, and found the "Body" under the "NewsFeed".
<complexTypename="NewsFeed">
<complexContent>
<extensionbase="ens:sObject">
<sequence>
<elementname="Body"nillable="true"minOccurs="0"type="xsd:string"/>
So I don't know why the program said No such column 'Body' on entity 'NewsFeed'.
Could anyone can help me?
Thanks!
PS: I have import the partner-18.jar and wsc-20.jar into my java project.
Your query is fine, but looking that jar files you referenced, I suspect you are hitting against an old version of the API. You want to be using v22
All Answers
Your query is fine, but looking that jar files you referenced, I suspect you are hitting against an old version of the API. You want to be using v22
Hi Wall,
I have change my jar files, they are partner-18.jar and wsc-22.jar now(the recent jar is wsc-22-jdk-1.5.jar, and my jdk is 1.6), so I use the wsc-22.jar. But the problem also appear.
"No such column 'Body' on entity 'NewsFeed'. "
It has to be API version related. Can you try executing your query via something like Soqlxplorer, or Eclipse to see if it you receive the same error.
Hi Wall,
Thanks for your help!
I have resolved this problem. I really have a wrong API. The partner-18.jar is not suitable for me. I downloaded the last version from salesforce.com and use it in my project. So, it can running now!
Thank you!