title: How to delete a page using wordpress rest api through curl
body: <p>I have done all pages listed in core PHP application using wordpress REST API with CURL but I can't delete that pages with CURL.I got message "{code: "rest_cannot_delete", message: "Sorry, you are not allowed to delete this post.}" every time. </p>
  
  <p>Here is my code.</p>
  
  <pre><code>$url = 'http://localhost/wordpress/wp-json/wp/v2/pages/37';
  $postdata = 37; //pageID
  
  function callrestapi_curlDelete($url, $postdata) {
  
      $postdata_json = json_encode($postdata);
      // Get cURL resource
      $curl = curl_init();
  
      // Set some options - we are passing in a useragent too here
      curl_setopt_array($curl, array(
          CURLOPT_URL =&gt; $url,
      ));
      curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
      curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata_json);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      // Send the request &amp; save response to $resp
      $resp = curl_exec($curl);
      // Close request to clear up some resources
      curl_close($curl);
  
      echo json_decode($resp, TRUE);
  
  }
  </code></pre>
  
  <p>Or if I tried via this code than I am getting the same error.</p>
  
  <pre><code>$.ajax({
        url: 'http://localhost/wordpress/wp-json/wp/v2/pages/15 ',
        method: 'DELETE',
        crossDomain: true,
        beforeSend: function ( xhr ) {
        xhr.setRequestHeader( 'Authorization', 'Basic ' + Base64.encode('admin:admin@123'));
        },
        success: function( data, txtStatus, xhr ) {
                 console.log( data );
                 console.log( xhr.status );
                              }
   });
  </code></pre>