1

I have a site set up that uses Craft as a CMS only, not used to display templates, as this is handled by React JS separately.

My site is set up so that Craft responds on /api.

I cannot for the life of me figure out how to POST data into a section!

I have a route set up, so my routes file is like:

return array(
    'post-message' => array(
        'action' => 'entries/saveEntry',
        'sectionId' => 13,
    ),
);

I am trying to test this using Rested app, posting a couple of fields into my section, but it doesn't do anything.

Rested is pointing to /api/post-message using a POST request.

I can't find any documentation that tutors a developer on how to post data into a section, so I'm completely stuck here.

  • Currently researching the best approach to use Craft as a headless CMS. May I ask how your set up of front- and backend looks like? Do you run the React frontend in a different environment? – rppld Mar 19 '17 at 21:08
2

If you don't want to get into plugin controllers and actions you can replicate this format here: https://craftcms.com/docs/templating/entry-form

And trick Craft into believing your data comes from an entry form.

  • Thanks for the hint. I have tried this to no avail, but I think there may have been a server POST issue that I have to investigate tomorrow. I'll get back to you... – designermonkey Nov 30 '16 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.