I am posting data to a custom View from my (Lotus Approach) database to my website using the services/xmlrpc interface.
I am hand coding everything in in my database in Basic.
I have successfully created a set of nodes from my database.
{user.login; node.save; user.logout with APIkey requires but not session id}
I now need to update a node.
To update a node I understand that I need to add to the node struct
the nid field and changed field thus.
<param>
<value><struct> <member><name>nid</name><value>413</value></member>
<member><name>changed</name><value>1215422409</value></member>
.... etc
However, When I try to update an existing node, the Node.save method returns the OLD node
and in the Drupal Log I get this message:
Duplicate entry '0' for key 1 query: INSERT INTO Ucontent_type_localchurch (field_postcode_value, vid, nid) VALUES ('QQ9 8JJ', 0, 413) in /var/www/html/sites/urc5.org.uk/www/includes/database.mysql.inc on line 172.
Can anyone please advise?
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | node_service.module.patch | 807 bytes | hurleyit |
Comments
Comment #1
DJL commentedI am still struggling to get a node to update.
I have located ONE error in my previous approach
my information above :-
was obtained from the node.save service page (admin/build/services/browse/node.save) generated by the services module.
which says
IT IS INCORRECT
Looking at the module code I see that It should read
I now get no SQL error (as the module does not attempt an INSERT.)
HOWEVER, the node.save updated still fails with
(Both in the DEV build and the official release)
Here is my updating XMLRPC
CAN anyone HELP?
CAN anyone at least point me toward some decent documentation?
Comment #2
DJL commentedI know it is summer (at least in the Northern Hemisphere)
but has anyone any clues on this one?
Thanks in advance
Comment #3
DJL commentedWondering if things were better in the DEV version, downloaded & installed that.
Looking at the code, in this version all that is needed to initiate an UPDATE rather than a save is to include the NID field
The line (in my code above)
<member><name>revision</name><value><int>1</int></value></member>is in fact superfluous.
In node_service.module, the line
should be replaced with
Comment #4
DJL commentedHaving got this far, I wondered if Drupal was remembering the user correctly between XMLRPC calls.
I created a new system method:
The hook:
The implementation
I then executed :
sessid = system.connect
User.login (sessid, key, username, password)
system.me (sessid, key)
user.logout (sessid,key)
system.me returned the correct user!
So why does node.save say that my node has been modified by another user?
Puzzled.
Comment #5
tomhung commentedIs there any resolution to this?
I am having the same problem.
Greg
Comment #6
DJL commentedEURIKA!!!
I think I have cracked it!!!
I looked at api.drupal.org at the drupal_execute module documentation
and made a guess at changing the code in "function node_service_save"
in the file "node_service.module"
in ... \services\services\node_service folder.
It seems to work!
Here is the full code of 'my' function - I am not into patches!
It
Comment #7
DJL commentedThis does seem to work.
So I have posted this comment to change the Status.....
patch (code needs review)
Does it work for other people?
Comment #8
marcingy commentedplease provide a patch in the corrrect format.
Comment #9
hurleyit commentedI have a patch that should work but it also removes the unneeded updated watchdog call. Let me know if I need to submit a new version.
Comment #10
marcingy commentedApplied only affects d5.
Comment #11
marcingy commented