There seems to be a problem with the Services module of Drupal 7 when submitting nodes using the node create reosurce, for example I can create nodes just fine, even with custom fields, but the problem is with term reference fields, the values never gets to them, here is an example:

var nodeCust={
  title: 'undefined test 1',
  name: 'admin',
  body: { 
    und: [
    {value:'sdasdasd', format:'full_html'}
und:[ {value: 'test placeholder'} ]

und:[ {tid:"1"}  ]

This is the object I send in JSON, and it works great the body has its value, the title and the custom field as well, but the "theterm" field is a term reference field in this content type, and it NEVER gets its value :o( , I tried with all the widgets, autocomplete, list etc but that should not really affect this since this is a REST Services call w/JSON.

Any ideas anyone? Thanks

  • This is just a stab in the dark, but to tids have a language code? Jul 21, 2011 at 13:19
  • 1
    Yeah at it seems as if they do, because I can quite easily return a full node object in JSON and it's the exact same representation, with language code es "en" or "und" for undefined. Other people who programatically was creating nodes were having problems with the locale module and term reference fields, but even with locale disabled no dice. :/
    – neph
    Jul 21, 2011 at 14:54

2 Answers 2


The structure of what you submit through the API should generally be the same as the structure of the data you submit through the ordinary node form as the resource methods for creating and updating nodes are simply thin wrappers around a form submit. Even the validation and most errors come from the form handlers.

So my suggestion is that you look at how the form submits stuff as that's where you will likely always find the answer.

  • 1
    Just to update, still no solution to this one after several weeks of testing different things. Beginning to think its a problem with the module or some other thing, even after using the exact same structure as the node form does, no dice :/
    – neph
    Aug 9, 2011 at 21:02
  • You can always create new resources on the server side - that might be an easier solution for you perhaps.
    – VoxPelli
    Aug 10, 2011 at 13:19
  • Yeah this is what I am thinking of doing, I actually created a resource which creates a node usnig node_save, and this way it works.. but it seems strange to me, im sure under the hood the modules use the same thing.
    – neph
    Aug 10, 2011 at 14:23

I've been having similar problems figuring out how to format my node objects as JSON. odly enough, it seem like you have to pass the tid in without the array notation, for example;

{ "title":"my title", "type":"my_type", "field_my_field_type": { "und": {"tid": "49"} } }

notice there are no brackets around und ... I have no idea why this works, since all of the other fields like body require that you format them with the brackets. I'm also getting different results when posting using poster (for firefox) and when posting the same JSON string in my app. Please let me know if you figure this out.

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.