Title: Rest API hook &#8216;rest_insert_post&#8217; not returning request object
Last modified: October 31, 2017

---

# Rest API hook ‘rest_insert_post’ not returning request object

 *  [HK](https://wordpress.org/support/users/hk1993/)
 * (@hk1993)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/rest-api-hook-rest_insert_post-not-returning-request-object/)
 * Rest API hook ‘rest_insert_post’ not returning request object
 *     ```
       function wp_api_add_tax($post, $request, $update = true){
            wp_mail('abc@gmail.com','test','data'.json_encode($request).  json_encode($post));
       }
       add_action( 'rest_insert_post', 'wp_api_add_tax',10,3 );
       ```
   
 * It should return entire request object in mail, But returns empty request object
   altho post object is coming with data

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/rest-api-hook-rest_insert_post-not-returning-request-object/#post-9642473)
 * I cannot replicate your experience.
 * Please try deactivating all plugins and switching to one of the default twenty*
   themes. Add your wp_mail code temporarily to the theme’s functions.php. Add a
   post through the REST API. You should now get a normal JSON post response and
   receive an email with the WP_REST_Request object, provided your server’s email
   sending is working correctly.
 * If you just need any kind of request listing for general reference, I can provide
   the result of my test. I output a var_dump to a file instead of JSON encoding
   to email, but the data is the same either way.

Viewing 1 replies (of 1 total)

The topic ‘Rest API hook ‘rest_insert_post’ not returning request object’ is closed
to new replies.

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [call](https://wordpress.org/support/topic-tag/call/)
 * [get](https://wordpress.org/support/topic-tag/get/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [request](https://wordpress.org/support/topic-tag/request/)
 * [response](https://wordpress.org/support/topic-tag/response/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/rest-api-hook-rest_insert_post-not-returning-request-object/#post-9642473)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
