1

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

2
  • 1
    I think you need to drop /entity from your post URL, also be sure non of the taxonomy views is overriding that path.
    – Ziftman
    Jan 2 at 23:51
  • 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.
    – DeniS
    Jan 3 at 20:13

0

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.