Skip Navigation

[Resolved] REST API Create Relationship

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

Problem:
Can we connect Posts with the REST API in a relationship?

Solution:
The Toolset REST Supports a "post" field which will not be saved as a post field but instead as a Related Post, see https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/#field-types-and-their-value-format-in-rest-api > post.

You'd add a related post ID to that REST endpoint (post)
It must be an existing post ID, and it must be connecting to an existing post of another type.

This support ticket is created 5 years, 6 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by steveL-12 5 years, 6 months ago.

Assisted by: Beda.

Author
Posts
#1308305

Tell us what you are trying to do?
Create a post using an already-existing custom post type and assign it to a parent post (differenct CPT) via a relationship using REST.

Is there any documentation that you are following?

https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/
and
https://developer.wordpress.org/rest-api/

Is there a similar example that we can see?
Not really, but think of it this way: I have a journal Volume CPT and an Issue CPT, such that a volume is a year's-worth of journals. Through REST, I want to be able to create an Issue and assign it to a Volume by also writing an entry into the existing many-to-one Issue->Volume relationship. Works fine in the GUI admin, but there seems to be no documentation in the Toolset REST docs to show how to create (or even read) relationship entries.

What is the link to your site?
hidden link

#1308553

The Toolset REST Supports a "post" field which will not be saved as a post field but instead as a Related Post, see https://toolset.com/documentation/programmer-reference/toolset-integration-with-the-rest-api/#field-types-and-their-value-format-in-rest-api > post.

You'd add a related post ID to that REST endpoint (post)
It must be an existing post ID, and it must be connecting to an existing post of another type.

This should allow you to proceed with the custom REST application you are working on.

#1310733

My issue is resolved now. Thank you!