Hello,
As the title suggests, I need to create a new node, using xmlrpc from Java.
The problem is this node has a user reference field that I need to fill.
I tried all of the following:
* [{uid => 1}]
* [{value => 1}]
* [{uid => 1}, {value => username}]

none of them worked... I get "found no valid user with that name".
Please Help!

Comments

ofridagan’s picture

Does someone know how to use node.save to create a new node with a user-reference field?
Thanks.

marcingy’s picture

Status: Active » Closed (won't fix)

so you raised this issue yesterday and then create noise today....this is not how to get help

ofridagan’s picture

sorry about the "noise"... didn't mean to cause any problems... it just a little urgent for me.
again, sorry.

ofridagan’s picture

Status: Closed (won't fix) » Active

I will really appreciated any kind of help.
Thanks.

rolf vreijdenberger’s picture

I'd suggest looking (finding) for the error message in the services module and then put some debug stuff in there, maybe the value of the 'name' that the error message suggest, to get some more info on what you are sending (or missing)
I have no experience on that specific matter.

ofridagan’s picture

Thanks!
The only message I get is: "found no valid user with that name".
I want to the line of code which produces this error:

function userreference_autocomplete_validate($element, &$form_state) {
  $field_name = $element['#field_name'];
  $type_name = $element['#type_name'];
  $field = content_fields($field_name, $type_name);
  $field_key = $element['#columns'][0];
  $value = $element['#value'][$field_key];
  $uid = NULL;
 if (!empty($value)) {
    $reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
    if (empty($reference)) {
      form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']) )));
    }
    else {
      $uid = key($reference);
    }
  }
  form_set_value($element, $uid, $form_state);
}

I tried to add to the error message the $value... strangely I only get the first letter of the username!
I even tried getting an existing node, and creating a new node, passing the exact value I received, for this field, and I still get the same error.

I'm having a hard time figuring out what this even has to do with "auto complete"... maybe I'm wrong.

If there is any other information that will help, please tell me.
Thanks!

ofridagan’s picture

OK, finally!
I changed the widget of the user reference field from auto-complete to select-list and that solved everything.
That's weird.. could not really find the reason.

rolf vreijdenberger’s picture

ok, thanks for posting an update.
did you use an http sniffer to see if you're sending different post/get data?
it might be in the structure of the data you're sending, it can still be a bug.

marcingy’s picture

Status: Active » Closed (works as designed)

The key is having the correct data structure and the structure is a fapi structure not a node structure.

newnewuser’s picture

I tried as ofridagan suggested in #7 (change to select list) unsuccessfully. Any other hints?
I ran into the same problem for node reference field. But for node reference field, I used "Autocomplete text field with create" (module noderefcreate) to solve the problem. I don't know how to circumvent problem for user reference field. Any help is highly appreciated.

Note: I use JSON not XMLRPC. Should it be part of a problem?