I am building a website and trying to pull the data from Wordpress using the WP rest api. On wordpress, the WooCommerce plugin has been added so the user contain more info and I have added additional field using a plugin.
First, how can I get all the user info ? incl. WooCommerce (mostly billing/Shipping) and also all the tother fields I have added using CIMY user extrafield
. I am coding in react but I do not really care about the react part.
I am more interested to understand, who WP handle it (endpoint) and a simple example with Postman is enough.
I tried /wp-json/wp/v2/users/user_id
and add the authorization token in the header but it's not working. it keep replying:
{
"code": "rest_no_route",
"message": "No route was found matching the URL and request method",
"data": {
"status": 404
}
}
Regards
I am building a website and trying to pull the data from Wordpress using the WP rest api. On wordpress, the WooCommerce plugin has been added so the user contain more info and I have added additional field using a plugin.
First, how can I get all the user info ? incl. WooCommerce (mostly billing/Shipping) and also all the tother fields I have added using CIMY user extrafield
. I am coding in react but I do not really care about the react part.
I am more interested to understand, who WP handle it (endpoint) and a simple example with Postman is enough.
I tried http://xx.yyy.zzz.aaa/wp-json/wp/v2/users/user_id
and add the authorization token in the header but it's not working. it keep replying:
{
"code": "rest_no_route",
"message": "No route was found matching the URL and request method",
"data": {
"status": 404
}
}
Regards
Share Improve this question asked Jul 8, 2020 at 2:26 SebSeb 1091 silver badge3 bronze badges 5 |1 Answer
Reset to default 0Since you're using a JWT for the current user (that is logged into WordPress), you can use this endpoint:
/wp/v2/users/me
https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user-2
You can also check the token to see what claims are available at https://jwt.ms
user_id
with the user's ID? – Jacob Peattie Commented Jul 8, 2020 at 3:21amartin
so I replaced user_id byamartin
– Seb Commented Jul 8, 2020 at 5:03