Score:1

What is the POST end point for taxonomy?

cn flag

I have a test script to create (POST) a term for a Tags vocabulary using cUrl. That simple script is working fine on Drupal 8.9.20, but it returns a 404 error on Drupal 9.3.0.

{"message":"No route found for 'POST \/entity\/taxonomy\/term\/taxonomy_term'"}

What is the POST end point for taxonomy terms?

I tried with different endpoints, but I get the same error message. In Drupal 8, they work.

In Drupal 9, I'm able to POST for nodes; I'm able to GET for taxonomy terms. It is only the POST for taxonomy terms that is causing problems. The Drupal 8 and Drupal 9 setups are clean default installations with only the Web Services modules enabled using Drush. Both are using the exact same Drush script.

This is the script I am using to query the end point.

endpoint="http://example.org/entity/taxonomy/term/taxonomy_term?_format=hal_json"
curl --request POST \
  -k \
  -i \
  -s \
  --user "${BOT_USERNAME}:${BOT_PASSWORD}" \
  --header 'Content-type: application/hal+json' \
  -H 'Cache-Control: no-cache' \
  "${endpoint}" \
  --data-binary "@${json_file}"

This is the JSON file used from that script.

{
  "_links": {
    "type": {
      "href": "http://example.org/rest/type/taxonomy_term/tags"
    }
  },
  "vid": [
    {
      "target_id": "tags"
    }
  ],
  "name": [
    {
      "value": "RESTtag",
      "lang": "en"
    }
  ]
}

These are the enabled modules and the resource settings.

screenshot

screenshot

Ziftman avatar
cn flag
I think you need to drop /entity from your post URL, also be sure non of the taxonomy views is overriding that path.
cn flag
Droping /entity doesn't work. I tried that before asking the question. I tried: /taxonomy/term/taxonomy_term?_format=hal_json, /term/taxonomy_term?_format=hal_json /taxonomy_term?_format=hal_json. I deleted all the views and still have the same issue.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.