I've been trying to update an entry using an AtomPub client - I'm using http://search.cpan.org/~miyagawa/XML-Atom/ . Reads work fine, but with updates I get:
Error on PUT http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/cgi-bin/mt/mt-atom.cgi/1.0/blog_id=1/entry_id=1: 500 Can't call method "body" on an undefined value at lib/MT/AtomServer.pm line 655.
The error is the same in MT 4.2 and 4.3 and I have repeated it in a couple of different environments.
Here's my test code, which updates the 1st blog's 1st entry:
#!/usr/bin/perl -wuse strict;
use XML::Atom::Client;
use XML::Atom::Entry;my $username = 'xxxxx';
my $password = 'xxxxx'; # Web services password from MT - edit profilemy $EditURI = 'http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/cgi-bin/mt/mt-atom.cgi/1.0/blog_id=1/entry_id=1';
/
my $api = XML::Atom::Client->new;
$api->username($username);
$api->password($password);my $entry = $api->getEntry($EditURI);
unless (defined $entry) {
print $api->errstr, "\n";
exit;
}my $title = $entry->title();
my $body = $entry->content()->body();print 'Title: ', $title, "\n";
print 'Old Content: ', $body, "\n";my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime time;
$body .= sprintf "<br/>Updated by AtomPub %4d-%02d-%02d %02d:%02d:%02d<br/>", $year+1900, $mon+1, $mday, $hour, $min, $sec;print 'New Content: ', $body, "\n";
$entry->title($title);
#$entry->content()->body($body);
$entry->content($body);my $res = $api->updateEntry($EditURI, $entry);
unless (defined $res) {
print $api->errstr, "\n";
exit;
}print "Program terminated normally\n";
Here's what I'm sending through the client:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<summary/>
<author>
<name>Administrator</name>
<email>rob@xxxx.xxx</email>
</author>
<published>2009-09-02T17:27:11+00:00</published>
<updated>2009-09-02T17:28:28+00:00</updated>
<link rel="alternate" href="http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/my_first_blog/2009/09/i-just-finished-installing-movable-type-4.html" type="text/html"/>
<id>tag:ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com,2009:/my_first_blog//1.1</id>
<edited xmlns="http://www.w3.org/2007/app">2009-09-02T17:28:28+00:00</edited>
<link rel="edit" href="http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/cgi-bin/mt/mt-atom.cgi/1.0/blog_id=1/entry_id=1" title="I just finished installing Movable Type 4!" type="application/atom+xml"/>
<link rel="replies" href="http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/cgi-bin/mt/mt-atom.cgi/comments/blog_id=1/entry_id=1" type="application/atom+xml"/>
<title>I just finished installing Movable Type 4!</title>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">Welcome to my new blog powered by Movable Type. This is the first post on my blog and was created for me automatically when I finished the installation process. But that is ok, because I will soon be creating posts of my own!<br/><br/>This time I installed it on a 2G bootable EBS volume.<br/><br/>Updated by AtomPub 2009-09-02 18:41:34<br/></div>
</content>
</entry>
Is this something wrong with my AtomPub client?
Reported on Movable Type 4.3
Hah... I fixed the EditURI and it works now:
my $EditURI = 'http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=1/entry_id=1';
I should have looked at the rsd.xml to get the right URI.