Get WP Navigation Menu from REST API V2

I’m trying to get the navigation menu from JSON response using WP REST API v2 plugin.

There is no navigation menu plugin extension for the REST API v2, but only for V1.

From codex WordPress Post Types, I learned that the navigation menu is treated as a post type.

From Rest API Doc, this is how we get posts of a type:

GET http://demo.wp-api.org/wp-json/wp/v2/types/<type>

I tried to get it like so:

URL : http://localhost/wptest/wp-json/wp/v2/types/nav_menu_item

I received 403 error.

{"code":"rest_cannot_read_type","message":"Cannot view type.","data":{"status":403}}

the server understood my request but it refused to give the data.

Q: How can I fix this?

7

There is a navigation menu plugin extension for the REST API v2: https://wordpress.org/plugins/wp-api-menus/

Leave a Comment