If you use plain permalinks and the withAPIData URL has parameters, the request fails because of two question marks.
Example: /index.php?rest_route=/wp/v2/users?context=edit&per_page=100 Failed to load resource: the server responded with a status of 404 (Not Found)
the same problem with
rest_route=/wp/v2/posts/id?force=true
that call with all languages but not English (United States)
Is this the correct call?
rest_route=/wp/v2/posts/id&force=true
But force=true is not the correct call to delete a post to trash
@RickorDD The force problem is a core wp-api.js bug: https://core.trac.wordpress.org/ticket/40672#comment:19
I expect the solution is to URL encode the REST path if it is appended to the root as a query argument?
Arguably might be the responsibility of the core wp.apiRequest to handle, since this is where the concatenation occurs:
Core ticket: https://core.trac.wordpress.org/ticket/42382
Taking a look at this...
It would be nice if Gutenberg could perform a common sense check in gutenberg_pre_init() to see if plain permalinks are being used and WordPress < 5..., or whichever version has the fix for TRAC 42382.
@aduth Could we shim this in Gutenberg for the time being?
@aduth Could we shim this in Gutenberg for the time being?
Probably. We could either replace the api-request.js dependency wholesale, or override buildAjaxOptions to modify options before calling the original function.
apiRequest.buildAjaxOptions = flow( [
( options ) => {
// Fix `options.path` ...
},
apiRequest.buildAjaxOptions,
] );
Fix at #4877
Most helpful comment
Taking a look at this...