user-pic

AtomPub client update fails

Vote 0 Votes

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 -w

use strict;
use XML::Atom::Client;
use XML::Atom::Entry;

my $username = 'xxxxx';
my $password = 'xxxxx'; # Web services password from MT - edit profile

my $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

1 Reply

| Add a Reply
  • 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.

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1773 6162

Last Topic: Excluding categories from blog by kholechek on Feb 9, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1429 5077

Last Topic: What apocalypse hit this community in the middle of 2011? by 75th on Feb 10, 2012

695 2910

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

173 737

Last Topic: About the MT version stated in HTML source by Alex E. Schneider on Feb 7, 2012

190 567

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012