Is there a fool-proof method to generate a correctly formatted JSON data object to be received by a create node resource given by a REST server, defined with Services in Drupal 7?
I have setup a REST server accepting the application/json
content type. I have also set up an anonymous endpoint with the create node
resource enabled and I managed to create a new item with the Poster plugin for Firefox with Content Type set to application/json
and the following data
{"title":"Review","type":"story"}
I can't seem to get any further though. I am following this guide and the node is created but my data for the rest of the fields is not added. I use this JSON editor to generate my code so it matches the structure shown by the dsm($_POST)
call I placed in node.module
's node_submit
handler for testing.
The JSON data I am trying to post looks like this (I remove all whitespace before using Poster):
{
"title":"great success!",
"type":"story",
"field_review":[
{"und":
[{"0":
[
{"value":"Some text"}
]
}]
}
],
"field_rating":[
{"und":
[
{"rating":"60"}
]
}
],
"field_product_type":[
{"und": "1"}
],
"field_barcode":[
{"und":
[
{"value":"33333333333"}
]
}
]
}
What am I missing?