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 callback function you have param $request that will provide you details from request, no need to use WP_REST_Request like that.
/**
* Creates parsed post based on content from Surfer.
*
* @param WP_REST_Request $request - request object.
* @return WP_REST_Response
*/
public function surfer_import_post( $request ) {
// Get Param
$something = $request->get_param( 'something' );
// Return response
return new WP_REST_Response(
array(
'message' => __( 'Hurray!', 'your_namespace' ),
),
200
);
}
Related Posts:
- Why is my custom API endpoint not working?
- WordPress 4.7 REST API endpoints
- Can I define multiple callback methods depending on the call method?
- Query the REST API for a Tag by slug
- Rest API Custom Endpoint with space character
- Is there anyway to format my EndPoint URL in WordPress?
- Custom Rest API POST endpoint with conditionally required parameters
- How to force JWT auth for default GET endpoints of WordPress rest api?
- WordPress Rest API custom endpoint for RSS feed
- Custom endpoint to get all custom taxonomy terms
- What’s the right way to validate JSON data coming from an AJAX POST request?
- How can I secure my custom rest api endpoint or add under a already existing rest group
- Securing REST API wp-json/wp/v2/users endpoint
- Delete row from table using custom endpoint via API
- Custom rest api endpoint response json problem
- Is the WordPress REST API installed and enabled in a vanilla WordPress 4.7 installation?
- WordPress Rest API custom endpoint optional param
- check the requesting url
- WP REST API Require Password for GET Endpoint
- How to use _embed when using _fields?
- WP REST API V2 – Retrieve sub page by full slug (URL/Path)
- WooCommerce: Can’t use wc_get_products for custom REST API endpoints
- Filter posts by multiple custom taxonomy terms using AND operator in REST API v2 (WordPress)
- How to get all posts from parent and children categories?
- How to force Authentication on REST API for Password protected page using custom table and fetch() without Plugin
- How to use the WP REST API for new user registration (sign up form)?
- Can I authenticate with both WooCommerce consumer key and JWT?
- Attach featured image to custom endpoints
- WordPress: How to create custom REST API route?
- WP REST API: check if user is logged in
- REST API URL parameters not working with apache server
- Adding post fields in wp-json/wp/v2/search
- Unable to get the info of the user which doesn’t have created any post via REST API
- WordPress Gutenberg get page template value when post updated?
- Can’t GET draft posts via REST API from headless frontend
- How to update custom meta fields with rest api?
- Rest API and Custom Fields
- WordPress REST API, Expired Nonce from Cache results in 403 forbidden
- WP Rest API: Get User by Email
- Application Password is not enable by default?
- Gutenberg Custom Block Getting All Posts
- Can we assume that /wp-json/ will always be /wp-json/ under any circumstances when creating custom REST routes?
- Passing a borrowed nonce through Postman fails
- How to hook into “register_rest_field” to modify the behavior of a custom field?
- Get all PDF files from page with WordPress API
- current_user_can(‘administrator’) returns false when I’m logged in
- How to add / embed an author into REST data from a custom post type?
- How to enable the view of revisions of post in WordPress Api for custom post type?
- Problem on creating custom endpoints for REST
- WP Remote Request not returning all of content via request
- New user signup via REST API
- Ho to style post content for WordPress API?
- WP REST API can’t set post tags
- WP API post__not_in is not working
- WordPress REST API V2: how to get list of all posts?
- Getting 401 from ajax using an application password
- How to connect android app with WordPress website?
- WordPress REST API calls that depend on the WordPress User
- Sidebar endpoint using WordPress API
- How to get data from /wp-json/wp/v2/users/me
- WordPress REST API parameters are not affecting a response
- Update meta_value in wp_postmeta using API
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- WordPress plugin with CORS
- WordPress REST API not working on localhost
- REST API – Allow /users endpoint depending on a custom capability
- “Error: cURL error 60: SSL certificate problem: certificate has expired” when create product in WooCommerce via REST API
- How to use WordPress REST api to login a user?
- Create User with Profile and Cover Images using REST API
- Wrong encoding of dynamic block properties problem when loggen in as editor
- Remove unwanted fields from WP API response
- Need wp rest api for featured video post
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- WordPress Update Role using API Cross site
- Rest API. Post content
- REST api header link href
- Error rest_post_invalid_page_number trying to call Rest API
- WordPress & React Native
- update meta data (like view counter) by rest-api
- Rest API hook ‘rest_insert_post’ not returning request object
- How Can I keep password protected posts in the json requests but not on frontend queries?
- REST API Integration without user account?
- WP_REST_Request::get_json_params() Parsing null as Zero
- Script tag in string in wordpress rest api body to create post
- Customizer Changeset, Sidebar and Rest API Custom Endpoints
- Rest API is running, but /wp-json/wp/v2/ shows only old dates
- Isn’t rest_do_request() filtered by pre_get_posts() filter?
- REST API Plugin Update call back not updating the plugin
- Accessing an auth protected custom WP API enpoint from remote origin
- Delay Issue: Using Wget with JSON Endpoint – Need Help Understanding Headers
- get posts from Rest Api by meta_key/meta_value not working
- REST API not Posting Content in Draft Mode
- REST API Schema: how to allows for both empty string or email string
- Displaying posts from one web site to another using REST API
- I made a webhook using snippet plugin, but is not working
- Filtering posts by ACF filed using WP Rest API
- register_sidebar has a bool param show_in_rest what are the repercussions of enabling it?
- I’m seeing “The response is not a valid JSON response.” on a wordpress site
- Field fetched through REST API contains ASCII version of special characters
- Setting default category on post update