When trying to create a FeedItem through the ApexRest I'm always getting the following error:

[{"errorCode":"APEX_ERROR","message":"System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Body]: [Body]\n\nClass.WS_SALES_V1_Document.post: line 61, column 1"}]

But according to the Salesforce docs, the Body field is Optional when Type is ContentPost.
Apex code of FeedItem creation(the insert fi; is line 61 by the way):

FeedItem fi = new FeedItem();
fi.ParentId = o.Id;
fi.Type = 'ContentPost';
fi.Visibility = 'AllUsers';
insert fi;

Is it a bug? Is documentation not up-to-date?


I'm using API version 36.0

  • 2
    As per the same doc If you set Type to ContentPost, also specify ContentData and ContentFileName. so give these two and then try. – Tushar Sharma Apr 29 '16 at 8:30
  • @TusharSharma thanks for the comment, but according to that same doc, both ContentData and ContentFileName are Available in API version 35.0 and earlier only. – Novarg Apr 29 '16 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.