I'm using EE as a REST API, consumed by a web app. My question is, how can I create a channel entry via post request from my Web App? I have a contact form whose data needs to be handled. That's all I need :) I've been researching the discussions around the web about using EE as REST API and microservices, but all I found is an add-on with a prize of $65 and a EE Open API, which for some reason I can't trigger, after the installation.
3 Answers
Essentially, you'll create a module with an ACT URL. (https://docs.expressionengine.com/v2/development/modules.html).
You'll have your mod.module_name.php
file, which will contain your logic to retrieve the data and enter it into the database using the Database Class (https://docs.expressionengine.com/v2/development/usage/database.html).
Then in you're upd.module_name.php
file, you'll need to ensure that you add records to the exp_actions
table, which will give you the ID for your ACT URL. https://docs.expressionengine.com/v2/development/modules.html#the-update-file-upd-module-name-php
if you want to take your API to the next level, you can check out this article: https://medium.com/expressionengine-cms/building-an-api-for-your-add-ons-with-expressionengine-and-the-a-team-85c1c9bc9e2c
-
Great resources and references - thank you! Especially the article on Meduim.– VladynJun 1, 2021 at 14:29
You could trigger this via an Addon (create a form action request) and when that is hit you can use the Model service to create a channel entry.
-
This is EE2 and I'm not sure I have the resource of writing my own add-on. What do you mean by "create a form action request"?– VladynJun 1, 2021 at 12:35
I've found this as a great solution - EE Open Api.
-
2Just a clarification for anyone reading this who is not working in EE2: the EE Open API has not had any development work done on it since 2014, and thus is unlikely to be useful for work with newer versions of EE. As noted on the EE Open API home page a better alternative is Webservice from Reinos which is qualified up to EE6. addons.reinos.nl/webservice Jun 10, 2021 at 12:51
-
This is an add-on that could complete your task and create a fully functional REST on EE. The only thing that stops me is the version I'm using, which 2.x, and the fact that this is actually paid one, while the Open API is free and compatible with 2.x. So good and important clarification anyway - thanks!– VladynJun 10, 2021 at 14:17