You need to sign in to do that
Don't have an account?
Add a comment to Post
Hi, i am trying to add a comment to a Post through java SOAP code.
Here is the code snippet-
..
string feeditemid= "0D53000000aZwx6CAC" (i.e- id of the Post to which i want to add the comment)
string comment= "This is a comment from me"
..
SObject s=new SObject();
s.setType("FeedComment");
s.setId(feeditemid);
s.setField("CommentBody",comment);
SaveResult[] results= connection.update(new SObject[]{s});
if (!results[0].isSuccess()) {
System.out.println("Error updating user status: "
+ results[0].getErrors()[0].getMessage());
}
else {
System.out.println("Comment added successfuly");
}
It is giving error-
Error updating user status: '0D53000000aZwx6CAC' is not a valid Salesforce ID for the type Feed Comment
Note-
The type of ID for FeedComment object, is of "reference" field type.
How to convert simple string ID to a "reference" type ID ?
Any other API function i need to call?
Web Services logic-
Successfully added comments!!!
All Answers
I think that when making a new comment you should supply the feed item id as the "feed item ID" not the "ID". The "ID" is generated after insertion into the database.
Hi Chris,
I am not supplying an ID, actually the value contained in the variable feeditemid is the Feed item id of a specific feed on my Profile Page. I retrieved this value by printing out the ID's of all the feeds on my profile page, feeditemid is one id of a feed among the list of feed item id's i have.
So, what is the solution?
Call s.setFeedItemId(feeditemid); instead of s.setId(feeditemid);
Chris,
Eclipse is giving error for the above method as "undefined method".
I also searched apex,soap,rest api's for the above method but didn't find it anywhere!
Solved by using Rest logic.
Web Services logic-
Successfully added comments!!!