Documentation for data requirements for creating nodes through the JSON Restful Server (Services 3, Drupal 7)

lhridley's picture

We have a project to complete for a client that involves setting up a restful web service backend for a set of mobile apps for Android and iOS. We have elected to use Drupal as our restful server and utilize the JSON service available through Services 3 along with the spyc library.

We have been able to locate precious little documentation related to the JSON data structures that need to be included with the content of a POST in order to create a node where additional fields have been added, so we are attempting to create this documentation through trial and error. At this point, we are stuck on the needed JSON data structure for a Taxonomy Term Reference field that stores unlimited multiple term references using either a select/checkbox or an autocomplete field on the Drupal UI web side of things.

If we understand correctly the data structure that works for a field using select/checkbox is different from the data structure for an autocomplete field. However, we have been unable to successfully determine what that data structure needs to look like in either case in order to create a node with multiple values stored in a Taxonomy Term Reference field.

At this time we can successfully create a node by posting a data structure that includes the following, which creates a single value in the Taxonomy Term Reference field, even if that field accepts multiple values:


However, passing multiple values errors out with a 406. We have tried a multitude of formats, including:

"field_taxonomy_test_multiple":{"und":{"tid":"2", "tid":"1"}}

"field_taxonomy_test_multiple":{"und":[{"tid":"2"}, {"tid":"1"}]}

"field_taxonomy_test_multiple":{"tid":{"tid":{"[tid:2]", "[tid:1]"}}}

All to no avail.

Any suggestions or help here would be greatly appreciated!


Having same problem

ernesto.sun's picture


Using D7 and Service/REST we face the same problem. We have several fields of type term-reference.

The REST-Service says to the POST: "An illegal choice has been detected. Please contact the site administrator."

Is there some active development on that issue? Isn't term-reference-POST an essential feature?

Any hacks maybe?

Thanks so much!

Problem solved for updating a taxonomy term ref field

deepcore's picture

Hi guys,

I had the same problem.
For just one taxonomy terms it works but not for multiple.

I am updating [PUT] a node like this:

"title":"Drupal article node",
"field_article_preferences" : {
"und": { "target_id" : "2" }

For multiple taxonomy term items you can do this:

"title":"Jakub Mroz",
"field_article_preferences" : {
"und": [1,2,3]

Where 1,2,3 are taxonomy term item ID's.

Life is a gift.
Dreams are just the beginning.
Drupal is our way.

Coupled w/ the Forms API

tyler.frankenstein's picture

Just a reminder that the data you POST/PUT for the Services module is always dependant on the form widget for the field.


Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week