[wp-xmlrpc] Updating Custom Fields Using metaWeblog.editPost

David Weiss dave at daveweiss.net
Tue Apr 7 04:17:42 GMT 2009


I can't seem to get the updates to custom fields to work on existing posts,
but creating new posts with custom fields seems to be working just fine.


Creating new post (Success!):

POST /wordpress/xmlrpc.php HTTP/1.0
Host: www.mydomain.com
Content-Type: text/xml
User-Agent: The Incutio XML-RPC PHP Library
Content-length: 961

<?xml version="1.0"?>
<methodCall>
<methodName>metaWeblog.newPost</methodName>
<params>
<param><value><int>1</int></value></param>
<param><value><string>********</string></value></param>
<param><value><string>********</string></value></param>
<param><value><struct>
  <member><name>title</name><value><string>430 N Michigan
Ave</string></value></member>
  <member><name>description</name><value><string>Hello
World!</string></value></member>
  <member><name>publish</name><value><boolean>1</boolean></value></member>
  <member><name>custom_fields</name><value><array><data>
  <value><struct>

<member><name>key</name><value><string>_listing_price</string></value></member>
  <member><name>value</name><value><string>300000</string></value></member>
</struct></value>
</data></array></value></member>
</struct></value></param>
<param><value><boolean>1</boolean></value></param>
</params></methodCall>

<?xml
version="1.0"?><methodResponse><params><param><value><string>569</string></value></param></params></methodResponse>


Editing an existing post (Fail!):



POST /wordpress/xmlrpc.php HTTP/1.0
Host: www.mydomain.com
Content-Type: text/xml
User-Agent: The Incutio XML-RPC PHP Library
Content-length: 989

<?xml version="1.0"?>
<methodCall>
<methodName>metaWeblog.editPost</methodName>
<params>
<param><value><string>442</string></value></param>
<param><value><string>********</string></value></param>
<param><value><string>********</string></value></param>
<param><value><struct>
  <member><name>title</name><value><string>430 N Michigan
Ave</string></value></member>
  <member><name>description</name><value><string>Updated Hello World
3!</string></value></member>
  <member><name>publish</name><value><boolean>1</boolean></value></member>
  <member><name>custom_fields</name><value><array><data>
  <value><struct>
  <member><name>id</name><value><string>442</string></value></member>
  <member><name>key</name><value><string>_listing_price</string></value></member>
  <member><name>value</name><value><string>300000</string></value></member>
</struct></value>
</data></array></value></member>
</struct></value></param>
<param><value><boolean>1</boolean></value></param>
</params></methodCall>

<?xml version="1.0"?><methodResponse><params><param><value><boolean>1</boolean></value></param></params></methodResponse>


The ID field in custom fields (442) is the ID for an existing, valid post in
the blog.  I've tried this value as a string, casted to an int, etc.  I
can't seem to make it work.

Any ideas or suggestions would be most appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://comox.textdrive.com/pipermail/wp-xmlrpc/attachments/20090407/17735535/attachment.htm


More information about the wp-xmlrpc mailing list