There is no such maxLength
option in the WP REST API.
You can pass a validate_callback
though. Example:
<?php
add_action( 'rest_api_init', function () {
register_rest_route( 'myplugin/v1', '/author/(?P<id>\d+)', array(
'methods' => 'GET',
'callback' => 'my_awesome_func',
'args' => array(
'id' => array(
'validate_callback' => function($param, $request, $key) {
return is_numeric( $param );
}
),
),
) );
} );
Source: https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/
Related Posts:
- How to define a query parameter with REST API?
- rest_sanitize_value_from_schema doesn’t sanitize string
- WP Rest API – Change response status code for failed validation request
- What’s the right way to validate JSON data coming from an AJAX POST request?
- Custom WP Rest API Endpoints from JSON Schema
- Does something like is_rest() exist
- REST API purpose?
- Get post count in wp rest API v2 and get all categories
- WP REST API — How to change HTTP Response status code?
- wp_get_current_user() function not working in Rest API callback function
- WP REST API Is it rather easy to rename the default wp-json uri part?
- Search WP API using the post title
- Understanding SHORTINIT with WordPress 5
- WP REST API returns blank response if post is too long
- Does pre_get_posts affect REST API responses?
- How to feed a HTML5’s EventSource with a REST API custom endpoint?
- How to Authenticate WP REST API with JWT Authentication using Fetch API
- WordPress 4.7 REST API endpoints
- wordpress wp-json prefix issue
- Get blog title with REST v2
- Is it possible to nest the JSON result of WordPress REST API?
- REST API multiple media upload
- 401 Error when trying to make a REST API call to site
- Create post using rest api with html content
- Does jQuery/Ajax send cookies when using the rest API or do I need to somehow add them?
- Trying to get an api request getting error 404
- Upload image to wordpress using REST API
- How should an old API version be deprecated gracefully?
- Full page NGINX (or Cloudflare) caching and WordPress nonces
- How add meta fields to a user with the wp-api?
- WordPress Rest API response
- WP 5.5 Fatal Error – get_rest_controller() in rest-api.php
- REST API GET users
- Why does AWStats show /wp-json* as Viewed URLs
- Display post title from WordPress excluding a string via API
- How send get request to external api with username and password
- WP_REMOTE_POST Requests are being blocked by API provider [closed]
- wp_get_object_terms() returns invalid taxonomy inside rest_api_init hook
- What is the proper way to validate and sanitize JSON response from REST API?
- Authenticating with REST API
- Make authorization mandatory on custom routes
- WP Rest API – How to convert embedded to json object in Java [closed]
- Why the Path is different with the one coded in rest
- WP REST API – Nonce passes wp_verify_nonce even after logout
- Setting maintenance mode via REST API
- How to receive data by http POST request
- WP API querying a custom post type and a custom field
- how to avoid timeouts with remote API requests?
- rest_api_init is run on every rest call to endpoint
- Notify Jenkins of new post on WordPress
- WP-REST create user with custom meta
- receive a custom parameter with rest api
- If I use WordPress REST API V2 and someone makes an app using it. Will my site count the posts views from the APP? And if not, then how?
- How to store and return json in a (custom) post meta field
- Sorry, you are not allowed to list users
- Get a remote post ID via API given URL
- Core function to check if a rest namespace exists
- How to change the date and time in REST API for comments?
- Rest API V2 custom post type. I only need the title and link
- Retriving all users with REST API not working
- Is there a way to download only the Rest API part of WordPress?
- Register GET REST API route with multiple parameters
- Custom WP API endpoint NULL body data
- WordPress HTTP API NTLM Authentication
- What is an endpoint for custom post type comments in REST API?
- How would I know if my system using REST api or not?
- WordPress custom REST API: How to validate input data by many context?
- Authenticate rest API except for contact-form-7
- How to access wordpress menu & submenu item through the REST API?
- How to display relations via wordpress Rest API
- Inspecting WP_Rest_Request
- WP Rest_API- Post request for images returns empty
- WordPress API fields modification
- DELETE request using WP REST API
- Fetching WordPress Private Posts, Public Posts Via Default REST API Endpoint
- How to deliver webp format of images to WP REST API
- WP Rest API in Android studio does not show Images
- Got Blank issue for get data from /wp-json/v2/post
- How do i POST to WordPress rest API from the same domain?
- WP API file_get_contents return TTP request failed! HTTP/1.1 401 Unauthorized
- Not able to delete media by REST API
- Update membership level via API request if using simple membership plugin
- Need to get user data via API
- REST API retrieving posts from www.sitename.com/category/news/ instead of just just from www.sitename.com
- REST API get featured image source for custom post type
- Custom rest API route not passing data along
- view counter update in WordPress REST api HTTP get
- How to filter wp-json/wp/v2/users response on custom metas?
- Paid membership Pro Rest API
- Trouble Commenting via the WP REST API using nonces
- wp_query json ouput
- GET request for media files in WP REST API 2 results in an empty array
- Fatal error: Call to undefined function register_rest_route()
- Create a new page on front page for logged in user
- API wp-json/wp/v2/pages/ returns a different result if page is specified
- Script tag in string in wordpress rest api body to create post
- Securing REST API wp-json/wp/v2/users endpoint
- oneOf JSON Schema validation not properly working for custom post meta value?
- Customizer Changeset, Sidebar and Rest API Custom Endpoints
- Rest Api Error ‘ Error: {‘code’: ‘rest_no_route’, ‘message’: ‘No route was found matching the URL and request method.’, ‘data’: {‘status’: 404}}@ [closed]