Last updated April 6, 2010. Created on July 13, 2008.
Edited by heyrocker, xolotl. Log in to edit this page.

I had the hardest time finding the right XML format to use to post to CCK fields via XML-RPC, until I found skaaal's hint in this issue.

So others might have an easier time, I'll post the example here. Note that this example was working on Drupal 5.8/CCK 5.x.1.7/Services 5.x-0.91...I can't promise that this format will work in other versions.

Here is a complete XML-RPC POST example. Note the additional nesting for the CCK fields (field_text, field_number):

POST /services/xmlrpc HTTP/1.0
User-Agent: XML-RPC for PHP 2.2.1
Host: somehost.com:80
Accept-Charset: UTF-8,ISO-8859-1,US-ASCII
Content-Type: text/xml
Content-Length: 1766

<?xml version="1.0"?>
<methodCall>
<methodName>node.save</methodName>
<params>
<param>
    <value>
        <struct>
            <member>
                <name>title</name>
                <value><string>Test</string></value>
            </member>
            <member>
                <name>type</name>
                <value><string>page</string></value>
            </member>
            <member>
                <name>field_text</name>
                <value>
                    <array>
                        <data>
                            <value>
                                <struct>
                                    <member>
                                        <name>value</name>
                                        <value><string>Hello world.</string></value>
                                    </member>
                                </struct>
                            </value>
                        </data>
                    </array>
                </value>
            </member>
            <member>
                <name>field_number</name>
                <value>
                    <array>
                        <data>
                            <value>
                                <struct>
                                    <member>
                                        <name>value</name>
                                        <value><double>22.60</double></value>
                                    </member>
                                </struct>
                            </value>
                        </data>
                    </array>
                </value>
            </member>
        </struct>
    </value>
</param>
</params>
</methodCall>

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

VincentBlouin’s picture

I used services-6.x-2.0, using the same syntax and it worked :)

federigasorin’s picture

I succesfully save a node with text field via xmlrpc service. Now i want to save a node with cck file field and i don't know the structure of it.
Thank you for the exmple for text field and number.
Sorin