Saturday, September 23, 2017

Retrieve EntityImage using SDK

In this example we will retrieve contact entity image

var Contact=Service.Retreive("contact","GUID",new ColumnSet(true));
byte[] entityimage=Contact["entityimage"] as byte[];

the above piece of code has no issues and ideally should Retreiveall the attributes of the contact as new ColumnSet(true) is specified but this will not get the entity image 

When you use RetrieveMultiple or Retrieve the EntityImage is not included when the ColumnSet.AllColumns property is set to true. Because of the potential size of data in this attribute, to return this attribute you must explicitly request it.
The binary data representing the image isn’t returned using the deprecated ExecuteFetchRequest class. You should use RetrieveMultipleRequestinstead.

Reference -