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
Keyur PatelKeyur Patel 

ContentDocument is not enabled for feed items of type ContentPost

Hi,

 

I got following issue while share selected slides or active work book in chatter with .Net. We are integrated chatter with our .Net application.

 

Error : 

{\"message\":\"ContentDocument is not enabled for feed items of type ContentPost\",\"errorCode\":\"INVALID_FIELD\"}

 

Here is my code.

=================================

byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + Boundary + "\r\n");

HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
if (this.Proxy != null)
wr.Proxy = this.Proxy;
wr.Timeout = 600000; // 10 minutes
wr.ContentType = ContentType + "; boundary=" + Boundary;
wr.Method = "POST";
wr.KeepAlive = true;
wr.ServicePoint.Expect100Continue = false;
wr.Headers.Add("Authorization: OAuth " + sessionId);
Stream rs = wr.GetRequestStream();

byte[] partBytes;
foreach (HttpMultipartRequestPart part in parts)
{
rs.Write(boundarybytes, 0, boundarybytes.Length);
partBytes = System.Text.Encoding.UTF8.GetBytes(part.ToString());
rs.Write(partBytes, 0, partBytes.Length);

if (part.BodyType == HttpMultipartRequestPart.BODY_TYPE_FILE)
part.WriteFile(rs);
else if (part.BodyType == HttpMultipartRequestPart.BODY_TYPE_BYTES)
part.WriteBytes(rs);
}

byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + Boundary + "--\r\n");
rs.Write(trailer, 0, trailer.Length);
rs.Close();

 

Please help me to short out this issue.

 

Regards,

Keyur Patel

alouie_sfdcalouie_sfdc
What's the value of your "url" variable?
alouie_sfdcalouie_sfdc
It looks like you're attempting to post a feed item containing a file attachment, and you're using a ContentDocument id in the URL. I don't think you should be using the ContentDocument id. Which feed are you trying to post the feed item to? A user profile feed? A record feed?
Keyur PatelKeyur Patel

Hi,

 

This is my URLhttps://test-developer123-edition.my.salesforce.com/services/data/v27.0/chatter/feeds/record/000000000AAA/feed-items

 

 

I am using Record feed.

alouie_sfdcalouie_sfdc
Hi, what's the actual record ID that you're using? (000000000AAA isn't a real ID). What record type is it?
Keyur PatelKeyur Patel

services/data/v27.0/chatter/feeds/record/069d0000000qpcyAAA/feed-items

Keyur PatelKeyur Patel

Hi,

 

I am sharing my selected slide in chatter from my .Net application.

 

I am using Record Feed Items and passing Parameters for attaching a new file.

 

jsonBody.attachment.attachmentType = "NewFile";
jsonBody.attachment.description = "test";
jsonBody.attachment.title = "FileName";

 

 

Reference Link : http://www.salesforce.com/us/developer/docs/chatterapi/Content/connect_resource_feeds_record.htm

alouie_sfdcalouie_sfdc
Everything looks good here, except that the record 069d0000000qpcyAAA is a ContentDocument record. It's actually not possible to post feed items to this record type (I'll see if the documentation can be updated to explicitly state this). Would it be possible to post it to a different feed?
Keyur PatelKeyur Patel

Yes, we can try with different feed. 

Keyur PatelKeyur Patel

I tried with User Profile (user-profile) feed but it is getting me a error.

 

[{"message":"Invalid subject identifier: 069d0000000qJnBAAU","errorCode":"INVALID_ID_FIELD"}]

alouie_sfdcalouie_sfdc

The subject identifier for the user-profile feed needs to be a user ID (user IDs start with "005") or "me".

Just to be clear: you can use any type of feed, including the record feed, but you can't use a ContentDocument ID as the subject ID.