Is there anyway to format my EndPoint URL in WordPress?

You don’t. Query args are not part of the route URL. Your endpoint URL is: https://iotkidsiq.com/wp-json/zaindob/v1/sync_order So needs to be registered as: register_rest_route( ‘zaindob/v1’, ‘/sync_order’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘updatetable’, ) ); key and msisdn are arguments that are sent to your endpoint. To define these use set the args property of the … Read more

pagination in WP rest api

define(‘API_ENDPOINT_VERSION’, 1); //flush the rewrite rules on plugin activation function apiendpoint_activate() { flush_rewrite_rules(); } register_activation_hook(__FILE__, ‘apiendpoint_activate’); function apiendpoint_register_endpoints() { register_rest_route( ‘api/v1’, ‘/post’, [ ‘methods’ => ‘GET’, ‘callback’ => ‘api_get_post’, ] ); } add_action(‘rest_api_init’, ‘apiendpoint_register_endpoints’); function api_get_post($request) { $ar = array(‘post_type’ => ‘posts’, ‘posts_per_page’ => 15, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘paged’ => ($_REQUEST[‘paged’] ? … Read more

Woo API REST : product variation price is read-only?

After some research, i found this example : PUT /wp-json/wc/v3/products/<product_id>/variations/<id> So in javascript we could do : const data = { regular_price: “10.00” }; WooCommerce.put(“products/22/variations/733”, data) .then((response) => { console.log(response.data); }) .catch((error) => { console.log(error.response.data); }); And the JSON API Response : { “id”: 733, “date_created”: “2017-03-23T00:53:11”, “date_created_gmt”: “2017-03-23T03:53:11”, “date_modified”: “2017-03-23T00:53:11”, “date_modified_gmt”: “2017-03-23T03:53:11”, “description”: “”, … Read more

Get all PDF files from page with WordPress API

You would get the PDFs by querying mime_type=application/pdf So, based on your example your full URL would be: https://www.domain.com/wp-json/wp/v2/media?parent=1267&mime_type=application/pdf However, it is possible when using the parent=ID parameter, you will see ALL the PDFs, not just the attachments specific to that post. This happens when the PDFs were uploaded to the media library, but not … Read more

Case insensitive header params for API request

This would seem to be a “fault” of the way WordPress (the “server”) is reading the HTTP request headers. (If they are being read into an associative array without any normalisation then the comparison will naturally be case-sensitive.) This should arguably be “fixed” in WP. However, it’s possible to create a “workaround” in .htaccess and … Read more

How do you format the set_body option for WP_Rest_Request?

WP_Rest_Request is not a way to make outgoing calls to remote REST APIs, it’s a data object core uses to pass around information about an incoming request. It’s basically something you recieved, it isn’t something you can send. If you poke your sites REST API with a request, WordPress creates and populates a WP_Rest_Request object … Read more

WP REST API GET Requests require authentication

I’ve been working on a similar issue today. Here’s what I’ve done: add_filter(‘rest_dispatch_request’, function($dispatch_result, $request, $route, $handler) { if (!is_user_logged_in()) { $dispatch_result = new WP_Error( ‘rest_not_logged_in’, __( ‘You are not currently logged in.’ ), array( ‘status’ => 401 ) ); } return $dispatch_result; }, 10, 4); You may want to use the $handler to determine … Read more

I am getting error message on accessing menu-endpoint

You didn’t change your prefix for that plugin’s API. Instead of /MC-ACF/wp-json/wp/v2/menus try /MC-ACF/wp-json/wp-api-menus/v2/menus That plugin developer states it right on the page you referenced in your question. If you’re wondering how I solved this. I’m not sure what your use case is, but there are newer versions of similar plugins as well. That one … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)