Closed fwatteau closed 4 years ago
Is there any chance that this will be fixed soon?
So if you update class-sp-rest-api.php the metrics rest field, so that the update_callback is recursive, then you this will work with your changes.
register_rest_field( 'sp_player', 'metrics', array( 'get_callback' => 'SP_REST_API::get_post_data', 'update_callback' => 'SP_REST_API::update_post_meta_recursive', 'schema' => array( 'description' => __( 'Metrics', 'sportspress' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'arg_options' => array( 'sanitize_callback' => 'rest_sanitize_request_arg', ), ), ) );
I don't know, i abandoned this plugin for custom dev.
So if you update class-sp-rest-api.php the metrics rest field, so that the update_callback is recursive, then you this will work with your changes.
register_rest_field( 'sp_player', 'metrics', array( 'get_callback' => 'SP_REST_API::get_post_data', 'update_callback' => 'SP_REST_API::update_post_meta_recursive', 'schema' => array( 'description' => __( 'Metrics', 'sportspress' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'arg_options' => array( 'sanitize_callback' => 'rest_sanitize_request_arg', ), ), ) );
Hi,
When i GET a player data by rest api (/wp-json/sportspress/v2/players/123), i'have the response : ` ... "metrics":{ "points": "500" },
`
But, when i PUT a player data with the same data in body, i've got an 400 error with message Paramètre(s) non valide(s) : metrics.
The problem are the conversion between PHP object and JSON.
Franck,