1

I want to POST a new taxonomy item. I'm using Postman in Chrome to test, I'm logged in fine, and I'm posting RAW JSON:

{
  "name": "building",
  "description": "",
  "vocabulary" : {
    "id" : 1,
    "resource" : "taxonomy_vocabulary",
    "uri" : "http://site/cms/taxonomy_vocabulary/1"
  }
}

And I just get this:

<?xml version="1.0" encoding="utf-8"?>
<result>Access denied for user anonymous</result>
2
  • Change the content type to application/json
    – Clive
    Sep 17, 2014 at 12:00
  • Thanks Clive, I had removed that accidentally. I've updated the question as I get a different message Sep 17, 2014 at 12:35

1 Answer 1

1

Here is the JSON format to add taxonomy term. I've tested it and works perfect.

{
    "vid": "2",
    "name": "Term Name",
    "description": "your description"
}

Here vid: vocabulary ID

Make sure the current logged-in user has privileges to add taxonomy term. and make sure to add token in Headers like follows

name: X-CSRF-Token

value: your-token

To know your token access the following path

yourdomain/services/session/token
2
  • 1
    Ah that's great, thank you! I find Drupals' messages and documentation lacking a great deal of sense and simplicity! Sep 17, 2014 at 12:53
  • 1
    @MarkRobson you're welcome. Glad you solved your problem. :) Sep 17, 2014 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.