I'm having a problem using some CCK form elements, such as the date picker and checkbox, with XML-RPC Services. When I create a field of that type, if I load the node then try to save it with no changes, I get a validation error. It appears that XML-RPC sends the raw value, but the code managing the field expects it to be broken up into the components and format used on the Web form.
I have reported this to the CCK folks, too. This bug report includes a detailed set of steps to reproduce: http://drupal.org/node/374558
Thanks!
Comments
Comment #1
scottgifford commentedI forgot to mention that if I change the fields to a simple date textbox and a multi-select list, everything works fine.
Comment #2
snelson commentedBecause the node.save process uses a drupal_execute, which is a programatic version of the node form submit, it expects the parameters to be passed in the same way as they would in a node form. Rule of thumb when trying to save nodes is to check the node form to see what its submitted data structure looks like.
Now, this is less than ideal as you should be able to do node.load and then node.save on the data that is returned, but until Drupal's data API is refined (this work is happening I believe), I don't think we have anyway around having to tweak the node before saving it.
Comment #3
greg.harveyI won't change the status, but just to note there's something weird going on here with drupal_execute. I'm surprised this is the only place I can find mention of this problem, but I'm experiencing it too - not via Services, but with a straight drupal_execute in a module full of code to import data from another website.
I suspect this should be re-directed, either to core or to CCK - probably CCK. I'll expand on Scott's original post over there and re-open it, I think. =)
Comment #4
aaroninaustin commentedWhat is the status of this issue? I am having the same issue in the 6.x code base, but unlike Scott, changing to a simple date select list did not fix the problem.
In my situation I'm using the date type created by datetools - and basically node.save just chokes when it encounters this. Everything thing else works just fine, I haven't tried any check boxes, just the date field.
Oddly though, I did some testing with the node_service.inc code and found that even if you change the drupal_execute() to a node_form_submit() I actually get the exact same behavior. Now I guess it could be node_form_submit is really calling drupal_execute() behind the scenes...
Not really sure where to go from here to keep debugging - if anyone can point me in the right direction that would be great.
Comment #5
scottgifford commented@aaronmontana: I ended up writing a custom service that converts between some standard format for XML-RPC and the internal format that the nodes expect. It was pretty straightforward once I read through the Services documentation.
Good luck!
Comment #6
marcingy commentedAs per comment in #3 this issue seems to be drupal excute itself
Comment #7
gweston commentedWould it be possible to get a sample of how to node.save with multiple checkboxes?
I can save one but can not seem to figure it out with multiple.
Comment #8
gweston commentedI got it like this
'field_services' => array(
array('value' => 'Service 1),
array('value' => 'Service 2')
),
Comment #9
gweston commentedYou can add dates via node.save with
$dateofbirth = array (
'value' => '1955-05-10T00:00:00',
'timezone' => 'UTC',
'timezone_db' => 'UTC',
'date_type' => 'date',
);
then in your node build function
'field_dateofbirth' => array(0 => $dateofbirth),
Comment #10
stillfinder commentedHello!
I have some problem with checkboxes and xmlrpc via services module. I write some application in C# and can't to send checkbox data to services. Maybe someone know in what format data must be sended?
With Date field I sending like this and all work perfect:
So we have an array:
Thanks to all for any help.
Comment #11
stillfinder commentedHi! I found solution for problems with cck fields (checkboxes and date time picker) and xml-rpc services node.save function
datetime cck field you need to send in following format:
[field_date] => Array
(
[0] => Array
(
[value] => Array
(
[year] => 2014
[month] => 7
[day] => 7
)
)
)
and CheckBoxes in this format:
[field_checkboxes] => Array
(
[value] => Array
(
[1991] => 1991
[1985] => 1985
)
)
Where 1991 is ID of taxonomy term.
If someone interested for C# code I can to send it.
Comment #12
Hacky commentedFOR JSON not worke please HELP
Comment #13
marcingy commentedPlease do not reopen random tickets.
Comment #14
beauz commentedI'm also having trouble saving a checkbox value via JSON, if anyone can help I have another issue here: http://drupal.org/node/1595366