0

I've figured out the basics of how to use a simple POST request to create a new Drupal 8 node. For example, using the JSON:API (https://www.drupal.org/docs/8/modules/jsonapi/creating-new-resources-post#basic-post-request) with a payload that looks like the following.

{
  "data": {
    "type": "node--article",
    "attributes": {
      "title": "My custom title",
      "body": {
        "value": "Custom value",
        "format": "plain_text"
      }
    }
  }
}

However, I have no control over the payload, and I need to create a new node from a JSON post request that looks like the following.

{
 "title": "My title",
 "message: "My Message",
}

The documentation and available examples for accepting POST requests I'm finding so far are few and far between, so just wondering if anybody has any guidance or examples to share.

I'm assuming we will need to implement a custom module of some sort to serialize/denormalize the payload, but the more I read the more I'm unclear about how to approach this or what exactly we need to implement. It has been a long day, and I'm just looking for the simplest approach to accepting a POST request like this to create a simple node.

Your Answer

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

Browse other questions tagged or ask your own question.