I am trying to create a node with image using drupal 7 REST server, I have configured REST server properly, I am able to create node with simple text as its body, I want to able to post image also i.e. I should be able to display image in newly created node or at least should be able to attach image to node body? so far I am doing it like this, how can I attach/display image in node's body? I am doing this via an external PHP script
$node_data = array(
'title' => "this is test node",
'type' => 'blog',
'body[und][0][value]' => 'this is test node description'
);
$node_data = http_build_query($node_data);
$cookie_session = $logged_user->session_name . '=' . $logged_user->sessid;
// cURL
$curl = curl_init($request_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json')); // Accept JSON response
curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST
curl_setopt($curl, CURLOPT_POSTFIELDS, $node_data); // Set POST data
curl_setopt($curl, CURLOPT_HEADER, FALSE); // Ask to not return Header
curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); // use the previously saved session
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
OK I am able to post images to newly created drupal node. I managed to do it by specifying the node body as "full_html". added following parameter in node_data array
'body[und][0][format]' =>'full_html'
with this I can post content as html content, hence image can be embedded in it.
BTW there are three options are available:
filtered_html
full_html
plain_text