How to post node tags using REST API? There is no problem with a node creation with filled in title/body/custom text field fields using REST API. We just need to send a post request with the following body:

{
  "_links": {
    "type": {
          "href": "http://localhost/drupal/rest/type/node/page"
    }
  },
  "title": {"value": "Does it work?"},
  "body": {"value": "node body"},
  "field_test": {"value":"hello"}
}


Where "field_test" is a plant text field.

But how to create a node with filled in tags field?

I've tried to post a node using the following post request body:

{
  "_links": {
    "type": {
          "href": "http://localhost/drupal/rest/type/node/page"
    }
  },
  "title": {"value": "Does it work?"},
  "body": {"value": "node body"},
  "field_tags": {"value":"tag1"}
}


It creates the node, but without tags ("field_tabgs") value.
Any help?
They are relations, so firstly you need to create the tags with the taxonomy REST service.

/taxonomy/term


You must take into account they are entities ( node and taxonomy_term ) and the field_tags field only stores the reference to the entity taxonomy_term.

Once you have created it, you will have to add the tags in the following way in your node definition.

Don't forget change the term_id ( in my case 1 ) and the uuid :

{
  "_links": {
    "type": {
      "href": "http://localhost/drupal/rest/type/node/page"
     }
  },
  "title": {"value": "Does it work?"},
  "body": {"value": "node body"},
  "_embedded": {
    "http://localhost/drupal/rest/relation/node/page/field_tags": 
      [
        {
          "_links": {
          "self": {
            "href": "http://localhost/drupal/taxonomy/term/1?_format=hal_json"
          },
          "type": {
            "href": "http://localhost/drupal/rest/type/taxonomy_term/tags"
          }
        },
        "uuid": [
          {
            "value": "ff61ea71-2540-47fe-a4bb-384b12d4de47"
          }
        ],
       "lang": "en"
      }
    ]
  }
}


More information in the following link.