I just spent 5 hours figuring this out so I want to post it here for those with the same problem.

I was trying to use the node service to update an existing node using node.save. I had to explicitly set the edit.uid and edit.user when making the object to call node.save with. Otherwise the node was always created as the anonymous user with uid=0. Also I had to have api and sessionId keys turned on.

Good luck

-josh

Comments

jrwjrw’s picture

I meant to say 'edit.uid and edit.name'. NOT edit.user. sorry

oknate’s picture

It took me a while to get node.save working in Flash with as3. The problem for me was that the data in the object has to be in nested arrays for custom CCK fields: It took me three hours to figure out that that's what the problem was. You have to create the same nesting in your actionscript object. Don't you hate when you're getting an error, and you have no clue what's causing it?

Anyway, here's what worked for me in Flash with actionscript 3.0 node service services:

var edit = new Object();
edit.type = "lead";
edit.title = this.title.text;
edit.body = this.body.text;

edit.field_firstname = new Array();
edit.field_firstname[0] = new Array();
edit.field_firstname[0].value = this.field_firstname.text;

edit.field_lastname = new Array();
edit.field_lastname[0] = new Array();
edit.field_lastname[0].value = this.field_lastname.text;

edit.field_companyname = new Array();
edit.field_companyname[0] = new Array();
edit.field_companyname[0].value = this.field_companyname.text;

edit.field_phone = new Array();
edit.field_phone[0] = new Array();
edit.field_phone[0].value = this.field_phone.text;

edit.field_fax = new Array();
edit.field_fax[0] = new Array();
edit.field_fax[0].value = this.field_fax .text;

edit.field_mailing = new Array();
edit.field_mailing[0] = new Array();
edit.field_mailing[0].value = this.field_mailing.text;

edit.field_bestcase = new Array();
edit.field_bestcase[0] = new Array();
edit.field_bestcase[0].value = this.field_bestcase.text;

edit.field_worstcase = new Array();
edit.field_worstcase[0] = new Array();
edit.field_worstcase[0].value = this.field_worstcase.text;

edit.field_email = new Array();
edit.field_email[0] = new Array();
edit.field_email[0].value = this.field_email.text;

edit.field_moreinfo = new Array();
edit.field_moreinfo[0] = new Array();
edit.field_moreinfo[0].value = this.field_moreinfo.text;
var saveResponder:Responder = new Responder(savedResponse, onFault);
myService.call('node.save', saveResponder, sessionID, edit);

alfarovive’s picture

Any idea if it is possible to load the noad using node.get modify the fields you want and then save that back with node.save?

I keep on getting this error... any idea what it means?

error correlationId:
error faultCode:AMFPHP_RUNTIME_ERROR
error faultString:array_key_exists(): The first argument should be either a string or an integer
error faultDetail:/home/.abidryer/omar/condechi.com/test/sites/all/modules/cck/modules/text/text.module on line 155

liquidcms’s picture

haven't gotten too far with existing handbooks on this stuff... sample php code to load/save a node would be so helpful.

if that is what you have done here; would sure be great if you could post.

joshon’s picture

Status: Closed (fixed) » Needs review

> I meant to say 'edit.uid and edit.name'. NOT edit.user. sorry

This fixed my problem.
If you have the access permissions on the content type of the node being updated set such that only the creator of the node can update it - you need to pass these through.

I suggest that the description of the node.save node argument read like this:
A node object. Upon creation, node object must include "type". Upon update, node object must include "nid" and "changed", and also "uid" and "name" if editing permissions are restricted.

HermosilloSoKRok’s picture

I'm having so much trouble to figure out CCK Fields on services. Everything works ok but when I test on the browse/node.save page the format you are using doesn't work. I haven't had any response so far and hoping someone can assist.

The way I read your examples, this should work:

{"type":"type_a","title":"why doesnt this work","uid":3,"name":"rocksocker","field_custom_a": [{"value":"test"}]}

Can someone please let me know if I am wrong

voxpelli’s picture

Title: node.save using services documentation » Improve node.save argument description
Version: 5.x-0.91 » 6.x-2.2
Status: Needs review » Closed (won't fix)

The CCK problem is discussed elsewhere - regarding improving the documentation I don't think this is needed any longer in 6.x-2.2 due to changes there so I'm mark this as won't fix. Please reopen if you feel differently.

(Services 0.x is no longer receiving fixes)