Hi All,
Hopefully someone can point me towards the right direction. We have a SaaS platform and trying to integrate our system with Drupal 7 backend. We want to create taxonomies with a vocabulary and I am getting this error and not sure what needs to be done to fix it. I am not a drupal developer and hence maybe its a module which need to be installed etc
I am passing the below dataset (POST request)
POST URL: {HOST}/taxonomy_term.json
Data JSON:
{
"vid": "1",
"name": "My First Tag",
"vocabulary_machine_name": "keywords"
}
Response:
406 Not Acceptable: Missing bundle: machine_name
Ref: https://drupal.stackexchange.com/questions/120580/how-to-create-taxonomy...
I have tried many other combinations, but no success yet.
Hope someone can help.
Thanks
Comments
Comment #2
dpp972 commentedHello,
I have excatly the same problem when i want to create taxomy term via RESTWS API (POST request).
Did you find any solution ?
Thanks
Comment #3
dpp972 commentedHi !
I found a solution. I simply disabled the bundle keys check from restws module resource creation process.
When a post request is sent and the restws api need to create a new resource (node or, in this case, taxonomy term), it uses the create() method from RestWSEntityResourceController class. This class is written in "restws.entity.inc" file inside the module directory.
I analyzed the code and it seems that, in order to the creation request succeed, both bundle keys and entity keys need to be set in the values array (corresponding to the request parameters set inside the POST request body).
But, in the case of taxonomy terms, bundle keys are not required to create the entity (there is only 1 bundle key for taxonomy terms : "machine_name". I think drupal need it for other purpose than creation...).
So, i added another condition for the bundle keys check process : entity type needs to be different from "taxonomy_term" ( see below)
The original code :
The new code :
As you can see, i just added "$this->entityType != 'taxonomy_term' &&" to the bundle check condition and it works properly now !
Hope it will help somebody !
Thanks.
Comment #4
avpadernoComment #5
lokapujyaSolution suggested in comment #3