• Resolved phungthien

    (@phungthien)


    I registered a rest route with POST method to call ‘createUser’ function. It’s working before with WordPress version 4.4.1.

    After I updated to the latest version of WP 4.4.2, it’s not working now.
    Please can you guys help me on this?

    function register_api(){
       register_rest_route( 'api/v1', 'createUser',
          array(
              'methods' => 'POST',
              'callback' => 'createUser',
             )
       );
    }

    https://ww.wp.xz.cn/plugins/rest-api/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    What else did you update when you updated WordPress? Nothing changed between WP 4.4.1 and 4.4.2 that should affect this, so it’s probably related to something else changing.

    When you say “not working”, can you be more specific? What’s the request you’re making, what response do you see, and what debugging have you already done?

    Thread Starter phungthien

    (@phungthien)

    Hi Daniel,
    Thank you for your reply.

    As you can see in my above comment, I created a route with POST method.
    I then made a request with this following url (http://nmng.trginternational.com/wp-json/api/v1/createUser). It actually worked before, but now it doesn’t. I got this error.

    {
    “code”: “rest_no_route”,
    “message”: “No route was found matching the URL and request method”,
    “data”: {
    “status”: 404
    }
    }

    I tried to change

    ‘methods’ => ‘POST’,

    to

    ‘methods’ => ‘GET’,

    then it worked (no error).

    Do you have any idea?

    Thread Starter phungthien

    (@phungthien)

    Hi Daniel,

    I’ve just figured out that I was using the wrong way to make POST request (silly me).
    It’s working now.

    Thanks again for you help 🙂

    Thread Starter phungthien

    (@phungthien)

    Ticket closed

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘POST method not working after updating WordPress’ is closed to new replies.