Questions tagged [rest-api]

Questions about the core RESTful HTTP API for accessing WP content and data.

Filter by
Sorted by
Tagged with
1
vote
0answers
24 views

Update a post based on results from GET request to another server

I need to use GET requests to retrieve the current status of a device and then update the body of a specific Wordpress post with the text data sent by the external device (for reference, it will use ...
0
votes
0answers
21 views

Wordpress improve REST API - SHORTINIT not work

i'm trying to improve the performance of Wordpress API custom endpoints. I created a plugin, simple file under plugin/PLUGIN_NAME folder where I call "register_rest_route" function to set the ...
1
vote
0answers
73 views

How to insert Comment metadata via REST API

I am trying to insert comment from my android app , i am using REST API and POST method /wp-json/wp/v2/comments/ The method is working great , but I would like to include metadata when inserting ...
0
votes
2answers
109 views

How to get all post of custom post type by rest api?

I have CPT transcript in wordpress website. And create 250 post in CPT transcript. Now, I want to fetch all transcript data and want to store in another database using rest api url http://example.com/...
0
votes
1answer
25 views

Should I worry about SQL injection when using REST API?

Should I worry about SQL injection when using REST API and sql queries via $wpdb? For example, is the bellow vulnerable to sql injection? public static function get_post( WP_REST_Request $request ) ...
1
vote
0answers
46 views

Create Session with JWT

I'm currently working on a shop like project that uses React as frontend and Wordpress with Woocommerce as a backend. To authenticate with the API I use the JWT Authentication for WP REST API, which ...
2
votes
1answer
149 views

Headless Wordpress: How to authenticate front end requests?

I am envisioning Wordpress on the back end to work with React.js on the front end like this: Wordpress is installed on http://example.com/api React.js script is loaded into http://example.com/index....
3
votes
0answers
554 views

x-wp-nonce is not allowed by Access-Control-Allow-Headers in preflight response

I would like my dev server on http://localhost:8080 to work with my wordpress install's rest api, of which the api base url is at http://localhost/wptest2/index.php/wp-json/ I am currently getting the ...
1
vote
1answer
62 views

Passing a borrowed nonce through Postman fails

I'm trying to test borrowing a nonce from my browser session so that I can use it elsewhere, namely in my npm dev environment. I took a nonce passed into an open Chrome browser session, put it in a ...
1
vote
1answer
294 views

pagination in WP rest api

We have made a custom API to get all the post in descending order and we want to add pagination in that API. I have read other questions and answers but didn't get the idea. Can anyone explain to me ...
2
votes
1answer
390 views

How do I correctly setup an AJAX nonce for WordPress REST API?

Following a link comment here which led me to these docs, I've tried to set up a nonce for user authentication. I added: wp_localize_script( 'wp-api', 'wpApiSettings', array( 'root' => ...
0
votes
1answer
139 views

Does jQuery/Ajax send cookies when using the rest API or do I need to somehow add them?

I've run into an odd situation with user capabilities. I have set up a rest endpoint on my local computer and am the super admin. The rest endpoint is called and the first thing it does is see if ...
0
votes
0answers
57 views

I can't post comment via REST API

I try to insert comment via REST API , but i get this error : Query parameter not permitted: author I followed this docs and author is one of the arguments this is the link test that i use https:/...
0
votes
0answers
194 views

Custom REST API with Stripe webhooks error: No signatures found matching the expected signature for payload

I've created an API endpoint listener for the Stripe "payment successful" webhook on our installation. add_action( 'rest_api_init', function () { register_rest_route( 'myplugin/v1', '/stripe', ...
0
votes
0answers
23 views

Can I set rest API endpoints from within a theme?

I would like to know if it is possible to set rest API endpoints from within a theme? I created a class to do this and made an instance of the class in the theme's functions.php file. This triggers ...
1
vote
0answers
34 views

Woocommerce REST API - updating an order changes custom tax calculations

We have a online woocommerce store that processes two types of orders: shipping and instore pickup. Shipping calculates taxes based on billing address and instore uses the store address (zip). ...
0
votes
1answer
52 views

register_rest_field update_callback don't work for $_FILES

I try to insert a post with REST API who contain text and image in one api call. My image is an acf field. I register my field like that: register_rest_field( 'project', 'logo', array( '...
-1
votes
1answer
22 views

Wordpress API standard compliance and specification for external database [closed]

HOW TO CONNECT WORDPRESS WITH EXTERNAL DB SERVER VIA API?
0
votes
0answers
16 views

How to rerieve comments and their replies from DB

I need to get comments and their replies from database to show them as json for an android app, so how can i tell if a comment has replies (get their number ) , and how can i list replies nested with ...
0
votes
1answer
94 views

Rest API: wp_verify_nonce() fails despite receiving correct nonce value

I am generating a nonce to be used with client side fetch requests to the rest api: function prepAllAdminScripts() { wp_register_script( 'reactAdminArea' , PLUGIN_FOLDER_URL . 'shared/...
0
votes
1answer
96 views

REST API and filtering by meta value

I have a posttype 'timeslip' and I am calling this with the following API endpoint: /wp-json/wp/v2/timeslip?meta_key=user_id&meta_value=1 I have exposed my custom field user_id to the API meta ...
0
votes
1answer
16 views

Is there anyway to format my EndPoint URL in WordPress?

I have wrote an endpoint in WordPress and it works just fine. The problem is with the URL. The current format of the URL request must be like this: https://iotkidsiq.com/wp-json/zaindob/v1/sync_order/...
1
vote
1answer
35 views

WP_Query To call data from diffrent tables

I need to retrieve data from multiple tables , wp_postmeta to get posts with a specific type ( question ) , wp_user for author informations and also wp_comments . I need those information to use them ...
1
vote
1answer
164 views

Return WP_Error as WP_REST_Response

I have a http request to WP REST API that can resolve in a success or a failure status The success gets handled by WP_REST_Response, and if any error occurs this is handled by WP_Error, both returned ...
0
votes
0answers
88 views

WooCommerce - Add product with Product category and Image from Mobile App

I am new to WooCommerce development and REST API provided by WooCommerce. I am facing 2 issues right to add new product as a vendor from my Mobile app which is in React Native. 1.I am adding new ...
0
votes
0answers
77 views

REST API list_user

I need to get a list of users by specific role. I user this endpoint: GET /users?roles=customer but I got: "code": "rest_user_cannot_view", "message": "Sorry, you are not allowed to filter users by ...
2
votes
1answer
30 views

WordPress REST get all items without a taxonomy assigned

i am a bit stuck right now. What i want to achieve is doing a request to the api that returns all posts that do not have a taxonomy assigned. I can do this request to get posts from a specific ...
1
vote
1answer
42 views

current_user_can('administrator') returns false when I'm logged in

protected function isAdmin() : bool { $check = current_user_can('administrator'); return $check; // returns false as I am logged in as superadmin, refreshing the page for xdebug to run }...
0
votes
0answers
42 views

Get templated page/post content via the WordPress API

I've been tasked with converting a WordPress site into a single page application so a persistent audio player can be added, while retaining its current theme. I need to do this in such a way that the ...
0
votes
0answers
54 views

Exclude categories in WP REST API response through function

I want to exclude some categories from the API response but not using the argument exclude but through function: When using the default route: https://example.com/wp-json/wp/v2/categories I want to ...
0
votes
0answers
79 views

How to get WordPress Theme Customizer options in the REST API?

I am trying to work with the WordPress REST Api as a backend for a React application. But I don't understand how to get/fetch the customizer options (check this image for example -> https://imgur.com/...
-2
votes
1answer
24 views

how to know that a wordpress plugin support using API?

i want to ask about wordpress plugins how i can know that the plugin support api and can be used to build apps with Rest-api and some platform like React Native to build apps. the plugin need users ...
0
votes
1answer
198 views

Get a remote post ID via API given URL

Given you have a URL, how can you get the post ID of a post on a remote WordPress site? As far as I can tell, you would have to: HTTP GET /wp-json/v2/posts And then look for your URL, but the ...
0
votes
1answer
14 views

What date to use as a post date? date_gmt or modified_date_gmt

I am consuming a rest service with the posts, and get both date_gmt and modified_date_gmt ... What realy is the difference ? Is the modified_date a publish date also? Any way, if I am presenting ...
0
votes
1answer
246 views

Updating link on page via REST api

I have a page that I need to periodically update the file location for a link to point at a new file. Trying to do this via a Python script using requests. I've got authentication set up via '...
0
votes
0answers
16 views

Creating Wordpress user remotely

I’m looking for a solution for my problem. Let me explain: I have two different websites. I’m listing my digital products on my first site. Users can purchase products through woocommerce. After a ...
0
votes
0answers
378 views

Restricting access to WordPress's REST API to localhost

In reviewing the WordPress REST API documentation, it's my understanding that the endpoints are publicly access thus when accessing www.domain.com/wp-json for example, it exposes the JSON construct ...
2
votes
1answer
130 views

Get loading state of wp data selector

I have a custom block that shows the assigned taxonomy terms for the current post. I'm trying to show a loading spinner while those terms are loading in the background. Let's say I have a selector ...
0
votes
0answers
82 views

How to update a user with REST API v2 knowing only the username?

I'd like to call WP REST API to update a user. I have only username, so I suppose I should retrieve user ID first of all, as the endpoint for updating a user is: GET /wp/v2/users/<id> How to ...
0
votes
1answer
314 views

Authenticating with REST API

I have tried every which way to authenticate a post request. WP User Plugin - As per the docs, I've logged in at wp-json/wpuser/v1/user/login and received my token. I've passed that token as a header ...
0
votes
1answer
86 views

Get user in rest API endpoint

I'm making some API endpoints that require me to confirm who the user is, and what they can do, before I let them use the endpoint. However, I can't seem to get the current user. My endpoint: ...
0
votes
2answers
562 views

Gutenberg Custom Block Getting All Posts

I'm trying to create a custom block but I need some assistance. I'm attempting to setup a <select> in the editor that lists all the posts. I'm not very experienced at the api yet but after ...
0
votes
0answers
48 views

Add Social Login(Google & Facebook) for woocommerce customer login

I want to add social login in woocommerce with much functionality like... 1) I have created android/iOS apps by using wordpress custom REST API. by using all API whole app is running. 2) if I ...
0
votes
1answer
45 views

Issues with Multisite installation and 403 error for REST API request

I have set up WP as multisite installation with subdomains. The dashboard for both the site network and each site is working fine, except for the error I get using Block Editor on my parent site. So ...
1
vote
0answers
39 views

WP rest api returns 404 only when author param is used

I have a multisite wordpress installation on aws linux, working perfectly fine. The WP Rest api is also working exactly as it should. Except for one single case. /wp-json/wp/v2/posts?author=<some ...
0
votes
1answer
193 views

What is an endpoint for custom post type comments in REST API?

In my react project i am using worpdress as backend and need to use my custom post type events comments also. So as per the WordPress documentation for comments API i am using an endpoint like this “...
0
votes
0answers
460 views

Test WordPress api with postman

I have some API endpoints. For example: add_action('rest_api_init', function () { register_rest_route(MY_APP_NAMESPACE, '/init', array( 'methods' => 'GET', 'callback' => ...
0
votes
0answers
27 views

Make plugin return HTTP 200 OK on POST

I am developing a custom plugin - payment gateway - which returns me data through POST request. The payment gateway is expecting this response: HTTP/1.1 200 OK Content-Type: application/x-www-form-...
1
vote
0answers
161 views

Blocks Rest API rest_cannot_delete

I'm trying to make a Postman call to the Wordpress API to delete a block. However, I keep getting a 403. This user is used to add and delete pages, tags, and posts just fine using the Application ...
0
votes
0answers
24 views

Getting Subscription Products from WooCommerce Subscriptions API

I am trying to access my site's Subscription Products via REST API. At wc/v1/subscriptions I can get the active subscriptions, and at wc/v3/products I can get all products except subscriptions. There ...