How to create paragraphs item programmatically? How to create paragraphs item programmatically?

In Drupal 7 I am using the following code.

    $node = node_load($nid);
    $paragraph = new ParagraphsItemEntity(array('field_name' =&gt; 'field_name', 'bundle' =&gt; 'para_bundlename'));
    $paragraph-&gt;is_new = TRUE;
    $paragraph-&gt;field_ptest1['und'][0]['value'] = 'Foo';
    $paragraph-&gt;setHostEntity('node', $node);
    $paragraph-&gt;save();
    node_save($node);


But its not working ?
Yes, That was for adding the value in existing paragraph item. If you want to create new paragraph item with new value try this code.

$node = node_load(...);

$paragraph = new ParagraphsItemEntity(array('field_name' =&gt; 'name_of_field_in_node', 'bundle' =&gt; 'name_of_paragraph_bundle'));
$paragraph-&gt;is_new = TRUE;
$paragraph-&gt;setHostEntity('node', $node);
$paragraph-&gt;field1_name_in_paragraph_bundle[LANGUAGE_NONE][0]['value'] = 'Test Data';
$paragraph-&gt;field2_name_in_paragraph_bundle[LANGUAGE_NONE][0]['value'] = 'Test Data';
$paragraph-&gt;save();