Create a node using services with PHP I want to add a new page node using drupal services and REST server.

$postdata = http_build_query(array(    
      'type' =&gt; 'page',
      'title' =&gt; 'aaa',
      'field_test[en][0][value]' =&gt; '&lt;p&gt;test&lt;/p&gt;\n',
      'field_test[en][0][format]' =&gt; 'filtered_html'
      )
);

$opts = array('http' =&gt;
    array(
        'method'  =&gt; 'POST',
        'header'  =&gt; 'Content-Type: application/json'."\r\n".
                     'Cookie: ' . $sessid."\r\n",                   
        'content' =&gt; $postdata
    )
);

    $context = stream_context_create($opts);
    $contents = file_get_contents($main_url."node", false, $context);

    echo json_encode($contents);


When I run above code I get an error:

Warning: file_get_contents(http://192.168.1.129:80/test/node) 
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 
401 Unauthorized: 
Missing required argument node in D:\xampp\htdocs\serv\server.php on line 61
I think that you need make an authenticated request, unless you want any user to create nodes. 
I have created nodes before using curl. You need enable the "Session authentication", activate the user login action in the resources section of you service, and enable request "application/x-www-form-urlencoded" in the server section.

This is the code

    $base_url = 'http://localhost/endpoint';
    $params = http_build_query(array(
       'username' =&gt; 'admin',
       'password' =&gt; 'qwerty',
    ));
    // set up the request
    $curl = curl_init($base_url . '/user/login.json');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
    // make the request
    $response = curl_exec($curl);
    curl_close($curl);
    $user_data = json_decode($response);
    // login successful
    if (isset($user_data-&gt;sessid)) {
      $node_params = http_build_query(array(
        'type' =&gt; 'page',
        'title' =&gt; 'Test page',
      ));
      // set up the authenticated request
      $curl_node = curl_init($base_url . '/node.json');
      curl_setopt($curl_node, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl_node, CURLOPT_POST, true);
      curl_setopt($curl_node, CURLOPT_POSTFIELDS, $node_params);
      curl_setopt($curl_node, CURLOPT_COOKIE, $user_data-&gt;session_name . '=' . $user_data-&gt;sessid);
      // make the authenticated request
      $node_response = curl_exec($curl_node);
      curl_close($curl_node);
      var_dump(json_decode($node_response));
    }