What’s wrong with my call to register_rest_route() ? Is it the way I’m
trying to access it?
This is the correct way to access that endpoint:
The route I’m trying to access is
http://site.test/wp-json/mchs/v1/search/[email protected]
But then you’re getting the 404 error because the path variable in the second parameter below, is not in the correct form of (?P<parameter name>regular expression pattern)
, including the round brackets ( (
and )
):
register_rest_route( 'mchs/v1', '/search/?P<search_email>\S+',
So you’re just missing the round brackets and thus just add them, i.e. use (?P<search_email>\S+)
, and the 404 error would be gone:
register_rest_route( 'mchs/v1', '/search/(?P<search_email>\S+)',
Additionally, you should always set a permission_callback
, even for public REST API routes, to avoid a _doing_it_wrong
notice. 🙂
Related Posts:
- wordpress custom endpoint multiple params
- Continue execution after WP REST API response
- what is the best practice to add new field to an api route
- Building a REST API for your web app exposes primary keys of DB records?
- Cant register rest routs from class instance
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- Looping through and combining calls to Woocommerce REST API
- get Woocommerce product format json for WP_Query
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- How to pass and validate nonce in custom REST routes
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- Authenticate + Authorize WP REST API request before built-in WP JSON Schema Payload Validation?
- WordPress REST API – Custom field not added to pages
- Custom plugin: Trying to show saved data on frontend
- Fatal error: Call to undefined function plugin_dir_path()
- How to loop through JSON data in wordpress WP REST API
- How to make WordPress plugin check for database changes and then do something?
- Retrieve multiple values passed to a single attribute in a shortcode
- How to make an meta_query optional?
- How to change date language without changing the entire site language?
- How to use copy() function and paste file in /wp-content/themes directory
- Why when I instantiate wp_error in a validation method my user registration method stops working?
- Am I not understanding plugins?
- Using Font Awesome as post thumbnail
- admin-ajax.php responding with 0
- Page Reloads Before AJAX Request Finishes
- How do I fetch all comments per post via WP REST API?
- Add htaccess rules with insert_with_markers at beginning of htaccess
- custom shortcode will not display the wrapped content
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- Insert array data on plugin activation
- Common abstract class for plugins
- Same log message keeps on printing to debug.log file thousand of times
- Is there an equivalent to WP_Error object I can return in the case of a successful REST request?
- Adding Default Settings to Theme My Login plugin
- Hide categories that are not used in the post type
- Automated Cart Update With Alert Box Each Time
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to sanitize any integer input field in wordpress?
- WordPress ajax doesn’t display object method on jQuery .change() function
- filter default query to show just selected level of child pages in wordpress
- How to make my custom widget appear within WordPress widgets? Plugin development
- Adding widgets to my plugin page instead of WordPress dashboard
- How to insert data into database using wp cron job
- I want to add custom add to cart link [closed]
- Execute long and heavy processes
- Access Child Class of Plugin Main Class Instance
- Font Awesome changing default WordPress Font
- Custom plugin settings link doesn’t append current class to menu item when visited? Why?
- Download full html page with CSV export plugin
- Using and saving custom dropdown boxes on user profiles
- Delete taxonomy and delete all post related it
- Problem with AJAX in wordpress plugin
- Usage of call back function of add_meta_box()
- How to set a template with wp_insert_post
- Multiple requests external data api dynamic block gutenberg
- how to save checkbox data for custom setting?
- Can a plugin redirect product page based on IF condition?
- Save html content of a widget textarea
- How to Schedule Cronjobs for start of every month and year
- Why does my settings form redirect to the homepage?
- WordPress WP_Query without query GET parameters
- How to clone all WordPress Rest API end points
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- How to override a plugins script
- Removed jQuery script from header.php , any problems?
- How can I get plugin meta data without knowing the plugin folder?
- calling admin-ajax.php from admin-ajax.php
- Post form – AJAX won’t upload featured image – Plugin development
- product_type_options get saved value [closed]
- Plugin won’t output characters with diacritics properly
- WP Hook Before a post is created
- ACF relationship on user profile page used for allowed access
- Store user form submitted information in post type
- Problem with my Login Plugin
- How to return html as a string from php for WordPress
- Sum All the Post Meta of Published posts of Current Logged in user
- Taxonomy Child Term, Counter is staying on 0
- Need help with format of nested array in MySQL
- How to add delete, approve, spam Links to Comments
- Help on Wp_query to print an term
- Upload images from one server to an other in wordpress
- Setting at job with shortcode not working
- Run code before WordPress loads and insert data into WP if need be
- PHP: Why does my code work in index.php but not a widget?
- How to use Amazon Elastic Transcoder from WordPress using AWS SDK for PHP?
- How to create “page” used for generating PDF? [closed]
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- How keep woocommerce users separeted in multisite install and keep admins on network
- I’m not able to get access $wpdb in my php file in wordpress
- How do I change the Go To Categories link in the term_updated_messages
- Import js variables loaded via wp_localize_script() into js module without global scope connection
- Custom taxonomy with page post type – WordPress
- Too few arguments at registering new templates in my plugin
- I want to lists posts in wordpress to nearest location entered by the user
- Displaying custom meta box value in a custom post page
- how to check elementor is widget is active or loaded
- Create a custom plugin with dynamic child pages listing database records