[wp-trac] [WordPress Trac] #41604: REST API: Attempting to create or update a non-existent setting doesn't return an error response

WordPress Trac noreply at wordpress.org
Mon Jun 16 06:14:26 UTC 2025


#41604: REST API: Attempting to create or update a non-existent setting doesn't
return an error response
--------------------------------------+--------------------------
 Reporter:  johnbillion               |       Owner:  johnbillion
     Type:  defect (bug)              |      Status:  reopened
 Priority:  normal                    |   Milestone:  6.9
Component:  Options, Meta APIs        |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-unit-tests has-patch  |     Focuses:  rest-api
--------------------------------------+--------------------------

Comment (by wildworks):

 I think `$request->get_body_params()` only works if the request is sent in
 form format. If the request is sent in JSON format (`application/json`),
 the parameters cannot be retrieved correctly.

 I think the endpoint needs to guarantee that it will work no matter which
 format the request is sent in.

 Theoretically, the following approach is possible, but it might not be
 suitable:

 {{{
 $params = array_merge(
     $request->get_body_params(),
     $request->get_json_params()
 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/41604#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list