跳转到主要内容
xiaohui717 提交于 27 February 2013

我在Drupal6.20里创建了一个自定义Content Type(customized_content), 然后在里面创建了一个字段(field_customized), 接着使用post json在这个Content Type中去创建一条记录, 这条记录是创建了, title还有type都有值, 但自定义字段却一直不能赋值, 请看下面的信息。能告诉我是json data的格式有问题吗? 还是有其他的问题。

Services Version: 6.x-3.3 Services Servier: REST json data: {"title":"project1001", "type":"customized_content", "field_customized->0->value":"test123456"}

使用AJAX post这个JSON data:   $.ajax({       url: "http://localhost:8080/gegdc/?q=xiaohui_service/node.json",       type: 'post',       data: '&node[title]=project1&node[type]=customized_content&node[field_customized][0][value]=test',       dataType: 'json',       error: function(XMLHttpRequest, textStatus, errorThrown) {         alert('node update error?);         console.log(JSON.stringify(XMLHttpRequest));         console.log(JSON.stringify(textStatus));         console.log(JSON.stringify(errorThrown));       },       success: function (data) {       }   });  

 

下面是Export endpoint xiaohui_service

 

$endpoint = new stdClass; $endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */ $endpoint->api_version = 3; $endpoint->name = 'xiaohui_service'; $endpoint->server = 'rest_server'; $endpoint->path = 'xiaohui_service'; $endpoint->authentication = array(   'services' => 'services', ); $endpoint->server_settings = array(   'rest_server' => array(     'formatters' => array(       'bencode' => TRUE,       'ical' => TRUE,       'json' => TRUE,       'php' => TRUE,       'rss' => TRUE,       'xcal' => TRUE,       'xml' => TRUE,       'jsonp' => FALSE,     ),     'parsers' => array(       'application/json' => TRUE,       'application/vnd.php.serialized' => TRUE,       'application/x-www-form-urlencoded' => TRUE,       'multipart/form-data' => TRUE,     ),   ), ); $endpoint->resources = array(   'comment' => array(     'operations' => array(       'create' => array(         'enabled' => 1,       ),       'retrieve' => array(         'enabled' => 1,       ),       'update' => array(         'enabled' => 1,       ),       'delete' => array(         'enabled' => 1,       ),       'index' => array(         'enabled' => 1,       ),     ),     'actions' => array(       'countAll' => array(         'enabled' => 1,       ),       'countNew' => array(         'enabled' => 1,       ),     ),   ),   'file' => array(     'operations' => array(       'create' => array(         'enabled' => 1,       ),       'retrieve' => array(         'enabled' => 1,       ),       'delete' => array(         'enabled' => 1,       ),       'index' => array(         'enabled' => 1,       ),     ),   ),   'node' => array(     'operations' => array(       'retrieve' => array(         'enabled' => 1,       ),       'create' => array(         'enabled' => 1,       ),       'update' => array(         'enabled' => 1,       ),       'delete' => array(         'enabled' => 1,       ),       'index' => array(         'enabled' => 1,       ),     ),     'relationships' => array(       'files' => array(         'enabled' => 1,       ),       'comments' => array(         'enabled' => 1,       ),     ),   ),   'system' => array(     'actions' => array(       'connect' => array(         'enabled' => 1,       ),       'get_variable' => array(         'enabled' => 1,       ),       'set_variable' => array(         'enabled' => 1,       ),       'del_variable' => array(         'enabled' => 1,       ),     ),   ),   'taxonomy_term' => array(     'operations' => array(       'retrieve' => array(         'enabled' => 1,       ),       'create' => array(         'enabled' => 1,       ),       'update' => array(         'enabled' => 1,       ),       'delete' => array(         'enabled' => 1,       ),       'index' => array(         'enabled' => 1,       ),     ),     'actions' => array(       'selectNodes' => array(         'enabled' => 1,       ),     ),   ),   'taxonomy_vocabulary' => array(     'operations' => array(       'retrieve' => array(         'enabled' => 1,       ),       'create' => array(         'enabled' => 1,       ),       'update' => array(         'enabled' => 1,       ),       'delete' => array(         'enabled' => 1,       ),       'index' => array(         'enabled' => 1,       ),     ),     'actions' => array(       'getTree' => array(         'enabled' => 1,       ),     ),   ),   'user' => array(     'operations' => array(       'retrieve' => array(         'enabled' => 1,       ),       'create' => array(         'enabled' => 1,       ),       'update' => array(         'enabled' => 1,       ),       'delete' => array(         'enabled' => 1,       ),       'index' => array(         'enabled' => 1,       ),     ),     'actions' => array(       'login' => array(         'enabled' => 1,       ),       'logout' => array(         'enabled' => 1,       ),       'register' => array(         'enabled' => 1,       ),     ),   ), ); $endpoint->debug = 0;  

标签
Drupal 版本