Drupal - How can I create a node via ajax call?

You can use Postman, a Google Chrome browser app that allows you to POST, GET, PATCH, and DELETE to any site (for testing purposes), to generate the code for you:

enter image description here

After completing the 3 steps shown in the picture, you need to perform 1 more step:

  1. Then paste the code into your custom module.

PS: I believe you can delete the postman-token line in the headers.


The issue was due to a bug in Rest UI module v.1.13 for D8.

As of writing this, the issue is not resolved on the module, but there is a workaround.

To get around the problem, configs exported from Rest UI need to be adjusted under "authentication".

See here for more info: https://www.drupal.org/node/2831716#comment-11813802

Tags:

Javascript

Ajax

8