Hello!
I work at Red Hat with iphands who submitted this patch:
http://drupal.org/node/1232984

Thank you so much for getting the above patch into Services 3! We are currently changing our requests from json to xml now that this is part of Services.

I encountered a problem when switching from json to xml, for creating or updating nodes, that happend when trying to post select type fields like "term reference" or "List" fields. The error was: "406 Not Acceptable: An illegal choice has been detected. Please contact the site administrator."

After a lot of troubleshooting I found the error occrued in includes/form.inc in the _form_validate method, because the data for the select option was an array and not a string.

I found the answer was to add the is_raw="true" attribute to value elements of select type fields and then it worked perfectly. For example:

  <field_kcs_tags_select>
    <und is_array="true">
      <item>
        <tid is_raw="true">10513</tid>
      </item>
      <item>
        <tid is_raw="true">10523</tid>
      </item>
    </und>
  </field_kcs_tags_select>

The following patch adds documentation to the code about when to use is_raw and why it's needed. Hopefully this will help someone else who may have the same problem when trying to create or update nodes with XML that have select or checkbox fields.

Comments

jared_sprague’s picture

I just noticed that this is exactly the same issue in this comment on the original xml request parser patch:
http://drupal.org/node/1232984#comment-6443630

Thanks heshan.lk!

Now with this patch the purpose of is_raw attribute will be documented in the parser as well.

ygerasimov’s picture

Status: Active » Fixed

Thanks! I have extended documentation with the example and committed it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

edited for accuracy