Correct filter hook to modify the output of a custom taxonomy API call?

The rest_grammar_terms_query hook should normally fire, but it’s possible that when registering the custom taxonomy or defining the API endpoint, that hook wasn’t applied or the wrong namespace was used. One approach would be to try using register_rest_field() or the rest_prepare_<taxonomy> filter. For example, rest_prepare_grammar_terms can be used to modify the API response of your … Read more

trying to send request-body to rest_api custom csp-endpoint

For sure, you are missing required argument permission_callback If you want this endpoint to be public you add it like this: ‘permission_callback’ => ‘__return_true’ It is tricky, because documentation do not tell you directly that this one is required. From version 5.5 you have only debug note that this argument is required. Also in your … Read more

Fetch a single post from a list of posts using the REST API

To help you, we need to know what the “my_post” action looks like in your code. Somewhere in your code, there must be an add_route with “my_post.” Can you show us what it looks like? add_route(‘my_post’, array( … )); By default, you can filter your posts in WordPress using the following route: ?rest_route=/wp/v2/posts/${POST_ID}.

WordPress Error uploading image: 401 API Python Script

When you’re using Basic Authentication, you can’t just pass the {username}:{password} string; you need to base64-encode it. libcurl docs on Basic Auth So your line ‘Authorization’: ‘Basic ‘ + WP_USER + ‘:’ + WP_APPLICATION_PASSWORD should be more like ‘Authorization’: ‘Basic ‘ + base64( WP_USER + ‘:’ + WP_APPLICATION_PASSWORD ) (I don’t know how Python does … Read more

Using backbone, can I prevent the nonce from being set?

Yes, the nonce is by default always being sent via the X-WP-Nonce header – see the source here and here on GitHub. wp.api.WPApiBaseModel.prototype.sync and wp.api.WPApiBaseCollection.prototype.sync can technically be extended or modified, but I would instead disable the nonce header like so, i.e. using <Collection or Model object>.endpointModel: Collection example: const Posts = new wp.api.collections.Posts(); // … Read more

REST API Schema: how to allows for both empty string or email string

even if I put in the schema ‘type’ => array(‘string’,’null’) I can’t POST a request with this field left empty, because WP always respond with rest_invalid_param and rest_invalid_email Actually, adding the ‘null’ there does not mean that any empty-ish values like ” and 0 will be allowed. It just means that an actual null value … Read more