Title: http status code in wp rest api
Last modified: December 20, 2016

---

# http status code in wp rest api

 *  [Gnanasekaran Loganathan](https://wordpress.org/support/users/gnanasekaran/)
 * (@gnanasekaran)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/http-status-code-in-wp-rest-api/)
 * How to change custom http status code in header in wp rest api
 * [https://wordpress.org/plugins/json-rest-api/](https://wordpress.org/plugins/json-rest-api/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Gnanasekaran Loganathan](https://wordpress.org/support/users/gnanasekaran/)
 * (@gnanasekaran)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/http-status-code-in-wp-rest-api/#post-8571043)
 * Use below function we can send HTTP status code
 * return new WP_REST_Response($posts, 200);
 * EX :
 * $return = new WP_Error( ‘rest_cannot_edit_others’, __( ‘You are not allowed to
   create posts as this user.’ ), array( ‘status’ => rest_authorization_required_code()));
 * $egr_reponse = array(‘error’ => $return->get_error_message());
    $code = $return-
   >get_error_code(); $status = $return->get_error_data($code); $status_code = $
   status[‘status’]; return new WP_REST_Response($egr_reponse, $status_code);

Viewing 1 replies (of 1 total)

The topic ‘http status code in wp rest api’ is closed to new replies.

## Tags

 * [status](https://wordpress.org/support/topic-tag/status/)
 * [wp rest api](https://wordpress.org/support/topic-tag/wp-rest-api/)

 * 1 reply
 * 1 participant
 * Last reply from: [Gnanasekaran Loganathan](https://wordpress.org/support/users/gnanasekaran/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/http-status-code-in-wp-rest-api/#post-8571043)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
