{"action":"created","issue":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/2908","repository_url":"https://api.github.com/repos/WP-API/WP-API","labels_url":"https://api.github.com/repos/WP-API/WP-API/issues/2908/labels{/name}","comments_url":"https://api.github.com/repos/WP-API/WP-API/issues/2908/comments","events_url":"https://api.github.com/repos/WP-API/WP-API/issues/2908/events","html_url":"https://github.com/WP-API/WP-API/issues/2908","id":187694481,"number":2908,"title":"Empty request in custom endpoints","user":{"login":"findshorty","id":1478044,"avatar_url":"https://avatars.githubusercontent.com/u/1478044?v=3","gravatar_id":"","url":"https://api.github.com/users/findshorty","html_url":"https://github.com/findshorty","followers_url":"https://api.github.com/users/findshorty/followers","following_url":"https://api.github.com/users/findshorty/following{/other_user}","gists_url":"https://api.github.com/users/findshorty/gists{/gist_id}","starred_url":"https://api.github.com/users/findshorty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/findshorty/subscriptions","organizations_url":"https://api.github.com/users/findshorty/orgs","repos_url":"https://api.github.com/users/findshorty/repos","events_url":"https://api.github.com/users/findshorty/events{/privacy}","received_events_url":"https://api.github.com/users/findshorty/received_events","type":"User","site_admin":false},"labels":[{"id":219479373,"url":"https://api.github.com/repos/WP-API/WP-API/labels/Support","name":"Support","color":"fef2c0","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-11-07T12:02:25Z","updated_at":"2016-11-09T14:35:43Z","closed_at":"2016-11-09T14:35:43Z","body":"After creating custom endpoints, any request made using anything but GET sends an empty request object to the custom callback, regardless of sending a JSON string or an array in the body of the request.\r\n\r\nConsider:\r\n```\r\nregister_rest_route( 'customapi/v1', '/account', array(\r\n\tarray(\r\n\t\t'methods' => WP_REST_Server::EDITABLE,\r\n\t\t'callback' => array($this, 'update_user'),\r\n\t\t'permission_callback' => function () {\r\n\t\t\treturn current_user_can( 'edit_posts' );\r\n\t\t},\r\n\t\t'args' => array()\r\n\t),\r\n\tarray(\r\n\t\t'methods' => WP_REST_Server::CREATABLE,\r\n\t\t'callback' => array($this, 'create_user'),\r\n\t\t'permission_callback' => function () {\r\n\t\t\treturn current_user_can( 'edit_posts' );\r\n\t\t},\r\n\t\t'args' => array()\r\n\t)\r\n));\r\n```\r\n\r\nThe callback, for simplicity, was changed to:\r\n\r\n```\r\npublic function update_user( WP_REST_Request $request) {\r\n\t$params = $request->get_params();\r\n\treturn new WP_REST_Response( array('params' => $params), 200 );\r\n}\r\n```\r\n\r\nAnd it's ALWAYS an empty array, regardless of using $request->get_params / get_body_params / get_json_params etc.\r\n\r\nThe request is made using wp_remote_request, PUT or POST, and basic authentication (which works fine)."},"comment":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/comments/259428603","html_url":"https://github.com/WP-API/WP-API/issues/2908#issuecomment-259428603","issue_url":"https://api.github.com/repos/WP-API/WP-API/issues/2908","id":259428603,"user":{"login":"BE-Webdesign","id":16389612,"avatar_url":"https://avatars.githubusercontent.com/u/16389612?v=3","gravatar_id":"","url":"https://api.github.com/users/BE-Webdesign","html_url":"https://github.com/BE-Webdesign","followers_url":"https://api.github.com/users/BE-Webdesign/followers","following_url":"https://api.github.com/users/BE-Webdesign/following{/other_user}","gists_url":"https://api.github.com/users/BE-Webdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/BE-Webdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BE-Webdesign/subscriptions","organizations_url":"https://api.github.com/users/BE-Webdesign/orgs","repos_url":"https://api.github.com/users/BE-Webdesign/repos","events_url":"https://api.github.com/users/BE-Webdesign/events{/privacy}","received_events_url":"https://api.github.com/users/BE-Webdesign/received_events","type":"User","site_admin":false},"created_at":"2016-11-09T14:35:43Z","updated_at":"2016-11-09T14:35:43Z","body":"Ah, glad to hear it was hard to gauge what was going on, as I am sure you probably felt the same.  Character encoding gives me nightmares."}}
{"actor":{"display_login":"BE-Webdesign"}}