Question:
How do I set a reference to a blog post entry in a CMS table using wix-data REST APIs?
Product:
WIX Data REST APIs
What are you trying to achieve:
I have an automation that creates a CMS entry when a new Blog Post (of a particular category) is created. The CMS table has a field called document that is a single reference to the Blog Post. Currently I have to update that reference by hand. As part of my automation I would like to update that reference automatically.
What have you already tried:
Iām trying the WIX Data REST API, method: āpostā, url: āitems/insert-referenceā.
It throws an exception:
āWDE0020: Provided property [document] is not a multi-reference fieldā.
If I change the document field to a multi-reference the code works, but really it needs to be a single reference field. So I feel this is probably the wrong API endpoint to be using.
Iāve also tried just doing a put with url = items/a6fc9dcc-fe33-4475-9117-fcd357be71e1, where that guid is the id of the CMS entry I want to update. This does update the field, but updates it with the ID of the blog, not the reference. So this also feels like the wrong approach. Maybe thereās some way to retrieve the reference number, and update the CMS record with that?
If only there was some way to get the reference ID.
Additional information:
I have a bad idea for an approach to this, which is to add a multi-reference field to the table, and in my automation put the reference there, then pull it out and put it into the single reference field. This will work, but oh what a hack.