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
WEN JIEWEN JIE 

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.

 

Best Answer chosen by Admin (Salesforce Developers) 
cloudcodercloudcoder

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

cloudcodercloudcoder

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

This was selected as the best answer
WEN JIEWEN JIE

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'. "

 

 

cloudcodercloudcoder

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. 

WEN JIEWEN JIE

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!