When you create a service endpoint you can enable various request parsers (application/json, application/x-www-form-urlencoded, multipart/form-data...) How should I decide whether to send the request using JSON vs form-data?
Most of the "node create" examples I've seen do something like this (I think this uses form-data):
//create a node
$node_data = array(
"title"=>"DHC Tool 01",
"type"=>"item",
"status"=>false, //ensure unpublished
"language" => "und", //lanugage neutral
"field_webpage"=>array(
"und"=>array(
0=>array("url"=>"http://berkeley.edu",)
)
)
);
// Use JSON
// $node_data = '{"title":"Tool Unpublished 10","type":"item","status":false,"language":"und","field_webpage":{"und":[{"url":"http:\/\/berkeley.edu"}]}}';
$options['data'] = http_build_query($node_data, '', '&');
$response = drupal_http_request($base_url . '/node', $options);
Is there any advantage to sending the node create request using JSON?
How would the above code be modified to use JSON?
Thanks!