Title: Rest API using POST method not working PHP 7.1 NGINX
Last modified: June 12, 2018

---

# Rest API using POST method not working PHP 7.1 NGINX

 *  [bishwadeep](https://wordpress.org/support/users/bishwadeep/)
 * (@bishwadeep)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/rest-api-using-post-method-not-working-php-7-1-nginx/)
 * Hi there,
 * I am having some issues with the REST API. Whenever I use ‘GET’ method, it works
   fine. However, ‘POST’ method results in following error.
    {“code”:”rest_no_route”,”
   message”:”No route was found matching the URL and request method”,”data”:{“status”:
   404}}
 * My server is NGINX with php7.1 wordpress version: 4.9.6
 * Here is the action hook I used.
    //rest api init
 *     ```
       add_action('rest_api_init', function () {
                   register_rest_route('test-url', '/submit-links', aarray(
                       'methods' => 'POST',//works perfect if GET method is used.
                       'callback' => array($this, submit_links_to_db),
                   ));
               });
       ```
   
 * Nginx URL rewrite:
    try_files $uri $uri/ /index.php$is_args$args;
 * There is noting in the error logs. Please let me know if you need more information.
   I would really appreciate any help.
 * Thank you

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/rest-api-using-post-method-not-working-php-7-1-nginx/#post-10400601)
 * The code you posted has a typo in line 2: `aarray(` instead of `array(`
 * The code in your installation must be OK, as this would generate an error log
   entry, but such an error would cause an API request to 404. Double check your
   actual code just to be sure.
 * I’ve no experience with POST endpoints. That said, maybe you should try adding
   a ‘permission_callback’. I don’t know if it’s actually required, but it would
   make sense if it were. Not just anyone authenticated should be allowed to add
   data, there are usually further restrictions that need to be checked.

Viewing 1 replies (of 1 total)

The topic ‘Rest API using POST method not working PHP 7.1 NGINX’ is closed to new
replies.

## Tags

 * [PHP7.1](https://wordpress.org/support/topic-tag/php7-1/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [7 years, 12 months ago](https://wordpress.org/support/topic/rest-api-using-post-method-not-working-php-7-1-nginx/#post-10400601)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
