EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set() I am creating nodes programmatically. I Have written following code,

$e = entity_create('node', array('type' =&gt; 'some_node'));
// Specify the author.
$e-&gt;uid = 1;
// Create a Entity Wrapper of that new Entity.
$entity = entity_metadata_wrapper('node', $e);

// Specify the title.
$entity-&gt;title = 'Some Title';
$entity-&gt;body = 'abc';
$entity-&gt;save();


On giving value to body i am getting following error. Commenting body it works fine


  EntityMetadataWrapperException: Invalid data value given. Be sure it
  matches the required data type and format. in
  EntityMetadataWrapper->set()


What is causing this error and how can I fix it?
Body is a Field API field and not a native PHP variable, therefore you cannot assign values to it like that. Instead, you would need to pass an array with the following keys:

$entity-&gt;body-&gt;set(array(
  'value' =&gt; 'This is the body',
  'summary' =&gt; 'This is the summary',
  'format' =&gt; 'full_html',
));


If you wish to set the value for a specific language, you call prior to set:

$entity-&gt;language(LANGUAGE_NONE); // or 'en' or whatever


More on wrappers: https://drupal.org/node/1021556