Hi,

I'm trying to use the node.save service method using XML-RPC from a Groovy application. I have Key Authentication enabled. I'm able to retrieve nodes using the node.get method.

The XML-RPC request i'm sending is:


POST /~james/drupal/services/xmlrpc HTTP/1.1
Content-Length: 790
Content-Type: text/xml
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.5.0_16
Host: 192.168.1.101:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

<?xml version="1.0" encoding="ISO-8859-1"?>
   <methodCall>	
      <methodName>node.save</methodName>	
      <params>		
         <param>
            <value>
               <string>cfde2b5cef02976c0e4c33180edfe913e31ef8a6694474037bb93dccaf87b025</string>
            </value>
         </param>		
         <param>
            <value>
               <string>localhost</string>
            </value>
         </param>		
         <param>
            <value>
               <string>1244312624325</string>
            </value>
         </param>		
         <param>
            <value>
               <string>87d1251c-e5b0-46b3-99c0-854b5b3e3dae</string>
            </value>
         </param>		
         <param>
            <value>
               <string>ak7tea4g1p0abquvkjs0f9vnc7</string>
            </value>
         </param>		
         <param>
            <value>
               <struct>
                  <member>
                     <name>type</name>
                     <value>
                        <string>Story</string>
                     </value>
                  </member>
                  <member>
                     <name>body</name>
                     <value>
                        <string>Hello</string>
                     </value>
                  </member>
                  <member>
                     <name>title</name>
                     <value>
                        <string>World</string>
                     </value>
                  </member>
               </struct>
            </value>
         </param>	
      </params>
   </methodCall>

The response i'm getting back is:


HTTP/1.1 200 OK
Date: Sat, 06 Jun 2009 18:23:45 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7l DAV/2 PHP/5.2.9
X-Powered-By: PHP/5.2.9
Set-Cookie: SESS5c72c03448fbc2a356ff1d17c6723e0a=okv96gobm6dufgqvqiq2qm7lc5; expires=Mon, 29-Jun-2009 21:57:05 GMT; path=/
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Sat, 06 Jun 2009 18:23:45 GMT
Cache-Control: store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Connection: close
Content-Length: 313
Content-Type: text/xml

<?xml version="1.0"?>
   <methodResponse>  
      <fault>  
         <value>    
            <struct>    
               <member>      
                  <name>faultCode</name>      
                  <value>
                     <int>1</int>
                  </value>    
               </member>    
               <member>      
                  <name>faultString</name>      
                  <value>
                     <string></string>
                  </value>    
               </member>    
            </struct>  
         </value>  
      </fault>
   </methodResponse>

A log message is being reported. It says:

Object of class stdClass could not be converted to string in /Users/james/Sites/drupal/sites/all/modules/services/servers/xmlrpc_server/xmlrpc_server.module on line 58.

Also, when I try to use the services testing page for node.save using the JSON string {"type":"Story","title":"Hello World","body":"Hello World Body"} I get a blank page and the request is not processed.

Any help is gratefully appreciated.

Cheers.

Comments

marcingy’s picture

Status: Active » Fixed

The browser element is now working. Note the node type should be story not Story. I'm going to mark this as fixed if you are still having issues make a note on this ticket.

parkijp’s picture

Hi marcingy,

Thank you for fixing the browser. That is now working great. I'm still struggling to get the service call to work from my application.

I've tried a number of different inputs. The first is using a JSON string. Is there a way to tell the service you are sending it JSON?

POST /~james/drupal/services/xmlrpc HTTP/1.1
Content-Length: 646
Content-Type: text/xml
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.5.0_16
Host: 192.168.1.101:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

<?xml version="1.0" encoding="ISO-8859-1"?>
   <methodCall>	
      <methodName>node.save</methodName>	
      <params>		
         <param>
            <value>
               <string>9cbd91c4444af7313a7e98d654bdc57296ebc02befe4b0c72c3c170328d2ff24</string>
            </value>
         </param>		
         <param>
            <value>
               <string>localhost</string>
            </value>
         </param>		
         <param>
            <value>
               <string>1244355053424</string>
            </value>
         </param>		
         <param>
            <value>
               <string>385720a4-b9f3-42c9-b90c-63c26133793d</string>
            </value>
         </param>		
         <param>
            <value>
               <string>76vjjq4af90f3kbmuvue8gem41</string>
            </value>
         </param>		
         <param>
            <value>
               <string>{"type":"story","title":"Hello World Again","body":"Hello World Body"}</string>
            </value>
         </param>	
      </params>
   </methodCall>

This second uses the struct but this time the type parameter is story.

POST /~james/drupal/services/xmlrpc HTTP/1.1
Content-Length: 807
Content-Type: text/xml
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.5.0_16
Host: 192.168.1.101:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

<?xml version="1.0" encoding="ISO-8859-1"?>
   <methodCall>	
      <methodName>node.save</methodName>	
      <params>		
         <param>
            <value>
               <string>429c48256b4f789b1f56dfcc5dae2ce19808e8ba5b09628fb44fa204af21f317</string>
            </value>
         </param>		
         <param>
            <value>
               <string>localhost</string>
            </value>
         </param>		
         <param>
            <value>
               <string>1244355316632</string>
            </value>
         </param>		
         <param>
            <value>
               <string>79ed5dee-cdd3-4d3e-9a5c-833e3f7667b6</string>
            </value>
         </param>		
         <param>
            <value>
               <string>rcu114u13n3pto0n82tqmvf2h4</string>
            </value>
         </param>		
         <param>
            <value>
               <struct>
                  <member>
                     <name>type</name>
                     <value>
                        <string>story</string>
                     </value>
                  </member>
                  <member>
                     <name>title</name>
                     <value>
                        <string>Hello World Again</string>
                     </value>
                  </member>
                  <member>
                     <name>body</name>
                     <value>
                        <string>This rocks</string>
                     </value>
                  </member>
               </struct>
            </value>
         </param>	
      </params>
   </methodCall>

Both the above fail in the same way as before.

Are there other parameters i'm missing in my request? Does the structure of the request look appropriate?

Is it possible to improve the error messages?

Thank you for working so hard on this and for your fast responses.

Kind regards.

parkijp’s picture

My fault. I've figured out what I got wrong. I was passing the wrong method name to the hash, which is why it worked great for node.get but not node.save.

Thanks for looking into this and for your help.

Cheers.

marcingy’s picture

Status: Fixed » Closed (fixed)