Skip Navigation

[Resolved] Toolset Rest Api Support

This thread is resolved. Here is a description of the problem and solution.

Problem:
The issue here is that the customer wanted to know if we have full support for the wordpress REST API

Solution:

Unfortunately no we currently don't have full REST support. What we have currently is for exposing the custom post types to the api for view purposes only.

50% of people find this useful.

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 16 replies, has 12 voices.

Last updated by stuart 6 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#605098
Rest Api settings.png

Hello,

I am reffering to this ticket: https://toolset.com/forums/topic/toolset-support-for-the-wp-rest-api/#post-444338 Has Adriano's code been merged in Toolset plugins and is it possible now to update a custom post field via Rest Api?

#605165

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ioannis,

Thank you for contacting our support forum.

Yes it is possible to update your CPT using the REST api as there is a setting now as you can see in the screenshot you provided to do enable the REST api for that CPT.

Please let me know if this helps.
Thanks,
Shane

#605205

Hello Shane,

thank you for your response! As Beda explains here https://toolset.com/forums/topic/how-to-send-an-api-post-get-request-via-cre/#post-526482 and Christian here https://toolset.com/forums/topic/exposing-custom-fields-through-rest-api/#post-505043 with these settings we can only choose in Post types whether to show or not Custom Posts in the REST. That's all, more can't be done yet but also they mention that the developers are going to add REST Support.

Has something changed from last year? I am trying to learn rest api but if it is not possible to update a custom post's fields, I should find another workaround and stop spending time to learn sth that I cannot use. That's why I am asking.

#605212

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ioannis,

I reviewed this with the team to gain some more clarity on this.

Currently the REST function only exposes Custom Post Types to the REST API for viewing and not for the full REST operations. Secondly Custom Fields are not available in the REST Api.

Thats as much information I have for now. The next thing is that reference was made to the code that Adriano wrote here
hidden link

But I can get in touch to see if there was any update on this.

Thanks,
Shane

#605258

Shane, please add my vote for the rest api support for custom fields. I believe that it would give much more power to toolset plugins and would help us build awesome applications. Thank you for providing the link from Adriano's code!

#612571

One more vote here. I am building an app and it would be great to have such integration.

#614754

Same - I'd prioritize custom fields, as CPT are relatively useless without those even for READ, but at some point Toolset needs full REST support. Surprised and disappointed this isn't already integrated.

#614990

Jay

I can't think of anything more important in 2018 than achieving full bi-directional REST-API support! +1 here!

#620772

Count another +1. Thanks!

#620832

Please implement the full support for the REST API! It's probably the most important thing to do right now.

#883148

Unfortunately, as much as I love Toolset, and the new relationships, the suite is fairly much dead in the water without support for the RestAPI.

I am having to migrate my sites to either ACF or Metabox.io even though their bi-directional relationships are not as nice in the admin.

#892959

Jay

Geoffrey, I'm in the exact same boat as you. So frustrating!

As much as I'm a huge toolset fan and super excited about the new relationships feature, I'm building progressive web apps via headless WP and Toolset has become absolutely useless to me without full REST API support.

Such a shame to have to use ACF or other solutions because of this, especially considering REST is in core now!

#948671

So I have great news. This is really easy just using this plugin
https://wordpress.org/plugins/wp-rest-api-controller/

And downloading a zip of this plugin and installing
hidden link (google github WP-API/Basic-Auth)

Then I just took the URL provided in the wp-rest plugin UI and did a post request for example and it inserted new toolset entity

//NodeJS like this
var url = "hidden link" + username + ":" + password + "@" + "example.com"
request.post(url,{form:data},....

request.get(url ... same to get all data

Let me know if you need any more info. NO PHP required!!! ?

#1119988

I still can't get it working for the custom fields. Does anyone have a working example how to format the custom fields?

#1171347

I'm glad I finally found this thread. I'm so frustrated trying to POST a new record that includes custom fields.

I have a CPT "car" with a CF "color" which is a string.

I'm using the plugins "JSON Basic Authentication" for authentication and "REST API Enabler" to be able to retrieve the values of the CF.

I can create an instance of "car" from wp-admin UI and successfully fetch it from the API.

* Notice I've manually removed some fields from the response below

{
    "guid": {
        "rendered": "<em><u>hidden link</u></em>"
    },
    "slug": "renault",
    "status": "publish",
    "type": "car",
    "title": {
        "rendered": "renault"
    },
    "wpcf-color": [
        "blue"
    ],
    "rest_api_enabler": {
        "wpcf-color": "blue"
    }
    ....
}

As you can see the custom field "wpcf-color" is present.

When I try to achieve the same using the REST API I misserably fail. I'm using node and the wpapi library like this:

const WPAPI = require('wpapi')
var wp = new WPAPI({
    endpoint: '<em><u>hidden link</u></em>',
    username: 'my-username',
    password: 'my-password'
});

// Define the CPT handler
wp.car = wp.registerRoute('wp/v2', '/car/(?P<id>[\\d]+)');

// Create a car
wp.car().create({
    title: 'volvo',
    status: 'publish',
    'wpcf-color': 'blue',
})
.then(response => console.log(response))
.catch(err => console.log(err));

The instance is created but the CF wpcf-color is not present.

Did anyone succeed in this?

Thanks!
Alex