1

I have created a new node using Services 3 module successfully, the code is below

{

 "type":"page",
"title":"New test page",
"taxonomy": { 
       "tid" :"367928"
      }

}

Configuration:

Drupal version = 6.26,

url = serviceurl/node,

App = Postman application in chrome,

Method = POST,

data = json.

But when i tried to edit the taxonomy term of the node using same format as below , its not working

url = serviceurl/node/node-id,

Method = PUT,

data = json.

{

"type":"page",
"title":"New updated title of the Page",
"taxonomy": { 
       "tid" :"367930"
      }
}

When I checked the node, the title is getting updated where as the taxonomy term remains the same. I searched a lot on the net, but could not find any solution. Can anyone please help to fix this issue.

0

I think your JSON format to create node is wrong. Please check the created node. I guess it creates node but with empty taxonomy field.

The correct format to create a node having taxonomy term is like follows.

Assuming that your 'widget type' for 'term reference field' is 'Select list' or 'Check boxes/radio buttons'

{
    "title": "my title",
    "type": "page",
    "field_mynodeterm": {
        "und": "3"
    }
}

here field_mynodeterm is machine name of your 'Term reference field' (which is used in content type).

Similarly you can use the same format to update the node

{
    "title": "my updated title",
    "type": "page",
    "field_mynodeterm": {
        "und": "5"
    }
}

If you use 'Autocomplete term widget (tagging)' as widget type for term reference field, the JSON format would be the following

{
    "title": "my updated title",
    "type": "page",
    "field_mynodeterm": {
        "und": "termname"
    }
}

I tested the above scenarios and working fine. Hope this helps.

  • Hi Krishna, I tried your solution. But the taxonomy is not saving if I use "photo_categories"(my taxonomy) method, because that field doesnot exist in my content type. Because I have a taxonomy called Photo Categories(machine name is 'photo_categories', which has 3 terms in it like "Sports", "Movies", and "News". And I enabled this taxonomy for Page content type. Hence there is no separate name for this taxonomy in my Page content type. Code is used is { "type":"page", "title":"Page test from Webservice1111", "page_categories": { "und": "367930" } } – harysh Oct 13 '14 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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