1
votes

I can save/update on regular fields but I'm having trouble saving/updating CCK fields. here's an example node.save() XML request - http://pastebin.com/m5ceca16

2
Are you getting any errors? Off-hand your request looks fine to me but the error might point us in the right direction. - Aaron
Did you ever get this figured out? - Aaron
yeah I used the a devel module to check the how the cck fields are setup and just follow it through to how i create my node and save it using node_save() thanks! - garrizaldy

2 Answers

1
votes

I'm assuming your XML data mirrors the node object format.

A CCK field 'field_custom' will be accessible via $node->field_custom. Regardless of type and the limit on number of entries, fields are always arrays. If the CCK field only allows one entry, it is $node->field_custom[0].

The indexes below that level depend on the field type. Most, especially numeric and text fields, are 'value' (eg., $node->field_custom[0] = 'foo'). I've used Nodereference fields which use 'nid', from which I would assume Userreference fields use 'uid'.

The structure of your XML seems correct. I would check the structure of a node object on the site (using a var_dump() or the devel module) to make sure all of your array keys and variable names are correct for your field and field type.

0
votes

2 things to check:

  1. A var_dump of the results of a node_load() doesn't give you the exact format you should use. Your XML must emulate the input format of the node edit form. So while a var_dump might show you several taxonomy terms in an array, the node edit form may expect the taxonomy terms separated by commas. Off-hand I don't see any fields in your example that this would seem to apply to but I mention it anyway.

  2. Your "changed" timestamp must not be in the future, nor must it be too far in the past. The node will not save if this is off by much. This can be an issue if the clocks on one of the computers isn't very accurate. I had an issue where my services server was about 20 seconds behind my services client so all the updates were getting rejected (the server apparently rejected them on the grounds that they were from the future).