Example: XML-RPC CCK Field XML Format

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

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>

Help improve this page

Page status: Not set

You can: