+ Start a Discussion
alibzafaralibzafar 

ContentType in FeedComment

I am testing to post file cotent to feedcomment from SOAP UI,  I am successfully able to post file to my feedItem but not in feedcomment. 

 

Here is my request xml for posting file content in feedcomment

 

 <sObjects xsi:type="FeedComment">
            <FeedItemId>${#TestCase#FeedItemId}</FeedItemId>
            <CommentBody>${#TestCase#Body}</CommentBody>
            <commentType>${#TestCase#ContentComment}</commentType>
 </sObjects>

 And here is the working one for feedItem 

 

<sObjects xsi:type="FeedItem">
           <ParentId>${#TestCase#ParentId}</ParentId>
           <Type>ContentPost</Type>
           <ContentData>${#TestCase#ContentData}</ContentData>
           <ContentFileName>${#TestCase#ContentFileName}</ContentFileName>
</sObjects>

 

I think there is some issue with order in how to send it, or I am missing few fields, see this link http://www.salesforce.com/us/developer/docs/api/index_Left.htm#CSHID=sforce_api_objects_feeditem.htm|StartTopic=Content%2Fsforce_api_objects_feeditem.htm|SkinName=webhelp

 

 

Thanks 

Best Answer chosen by Admin (Salesforce Developers) 
ShozubQShozubQ

Hey alibzafar -

 

For RelatedRecordId you have to pass in the contentVersion Object ID and not the ID of the file. This starts with '068D...'

There can be multiple versions of a file and the RelatedRecordId takes in a single one.

 

Source: http://www.salesforce.com/us/developer/docs/api/index_Left.htm#CSHID=sforce_api_objects_feeditem.htm|StartTopic=Content%2Fsforce_api_objects_feeditem.htm|SkinName=webhelp

 

Hope this helps!

Shozub.

All Answers

ChrisOctagonChrisOctagon

What is the error you are getting?

 

According to the docs, there is a field called RelatedRecordId you can use to provide an existing content version ID for the file to include in a comment.

 

Alternatively, you can use the Chatter REST API to upload a new file as part of posting a comment

alibzafaralibzafar

I am getting error "Invalid Reference ID ". I tried RelatedRecordId but it didn't work. I guess <contentData> and <contentFileName>  should be available in FeedComment , but currently salesforce doesn't expose this in feedComment. Not sure if there is any other way around. 

 

Thanks 

ChrisOctagonChrisOctagon

What type of ID did you set for RelatedRecordID?

alibzafaralibzafar

I am setting the same RelatedRecordID which I am setting in <ContentData> tag in FeedItem. Here is my request for posting file in feedcomment using  relatedRecordId 

 

<sObjects xsi:type="FeedComment">
           <FeedItemId>${#TestCase#FeedItemId}</FeedItemId>
           <CommentType>${#TestCase#ContentComment}</CommentType>
           <CommentBody>${#TestCase#Body}</CommentBody>
           <RelatedRecordId>${#TestCase#CommentTypeContentComment}</RelatedRecordId>
        </sObjects>

 

This runs successfully , but doesn't upload my file in comment, just post the content in Body. If I remove the Body tag, it says Required fields is missing, though this shouldn't be happening as salesforce api document says a text entry is optional if the CommentType isContentComment. I am setting my file name file.txt in ContentComment. 

 

Thanks 

ChrisOctagonChrisOctagon

What does the value that you're passing for RelatedRecordID look like? What 3 characters does it start with?

 

What you say "this runs successfully, but it doesn't upload my file in comment" do you mean that you see no file on the comment in Chatter?

alibzafaralibzafar

The ID I am passing for RelatedRecordId starts with '069D...' , Its a salesforce record ID of a file already uploaded.  

 

Yes I cannot see any file in my chatter comments. 

 

Thanks 

ShozubQShozubQ

Hey alibzafar -

 

For RelatedRecordId you have to pass in the contentVersion Object ID and not the ID of the file. This starts with '068D...'

There can be multiple versions of a file and the RelatedRecordId takes in a single one.

 

Source: http://www.salesforce.com/us/developer/docs/api/index_Left.htm#CSHID=sforce_api_objects_feeditem.htm|StartTopic=Content%2Fsforce_api_objects_feeditem.htm|SkinName=webhelp

 

Hope this helps!

Shozub.

This was selected as the best answer
alibzafaralibzafar

Hey Thanks, actually that works :-) 

 

so, here is the final working request xml for posting file in comment 

 

        <sObjects xsi:type="FeedComment">
<FeedItemId>${#TestCase#FeedItemId}</FeedItemId>
           <CommentType>${#TestCase#CommentType}</CommentType>
           <CommentBody>${#TestCase#Body}</CommentBody>
           <RelatedRecordId>${#TestCase#RelatedRecordId}</RelatedRecordId>
        </sObjects>

 Values I passed, 

 

ConentComment in CommentType 

ContentVersion Id in RelatedRecordId  (which starts with '068D').

 

Thanks 

Geetha ReddyGeetha Reddy

HI,

 

Can u explain the procedure for twitter in salesforce chatter.

 

That means when we tweet in twitter that must come in salesforce chatter.

 

Thanks in advance.