Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#42877 closed defect (bug) (invalid)

Rest routes 404ing when setting permalink to default

Reported by: neesu's profile neesu Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.1
Component: REST API Keywords:
Focuses: Cc:

Description

Hi Team,

I have registered custom routes and endpoints using register_rest_route() method. The routes are working fine with all permalink settings except default permalink.

I have changed the rest url prefix to my own. So for example lets consider one of my routes here i.e
http://example.com/neo/v0/users

So, neo is replacement of wp-json.

v0 is namespace.
/users is endpoint.

As explained, it is working fine with all permalink settings except default. To get this working, I have to add query string rest_route to the url.

i.e : http://example.com/?rest_route=/v0/users. But its not solution, when the route is using by any third party.

The third party would not change the hitting routes according to the WordPress permalink settings.

It would be appreciated for any help.

Change History (1)

#1 @dd32
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi @neesu

as you've discovered, permalinks need to be enabled for /wp-json/ to be used, clients cannot simply assume that the rest api is available at example.com/wp-json/.

For details of how clients should discover the URI to the rest api, see this handbook page:
https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/

I'm closing this as invalid as it's currently working as expected.

Note: See TracTickets for help on using tickets.