• Resolved tiwastudio

    (@tiwastudio)


    Hi WordPress REST API’s team

    I have read Plugin Document carefully but couldn’t find any example of how to retrieve data in body from POST request. What was written in the document is to show how to create custom endpoint for GET method. Now I can only read variables attached to URL like this
    register_rest_route( 'myplugin/v1', '/something/(?P<somedata>\S+)', array(...) );

    But still have no idea how to read body data in POST Request.

    Thanks in advance.

    https://www.ads-software.com/plugins/rest-api/

Viewing 1 replies (of 1 total)
  • Thread Starter tiwastudio

    (@tiwastudio)

    Okay I resolved this problem by googling further. I can let jQuery send POST data as application/json and in my custom endpoint I use this code to read body data from POST request json_decode(file_get_contents('php://input'))

    Cheers!!!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Endpoint : how to get data in body from POST method’ is closed to new replies.