Blogger API > XML-RPC >

Alert This documentation is provided for historical interest only. The Blogger 1.0 API is no longer supported and must not be used for new client development. Please use our GData API instead. — phopkins, 4/2007

blogger.setTemplate via XML-RPC

By Evan Williams, 8/13/01

blogger.setTemplate changes the template for a given blog. Can change either main or archive index template.

URI

All XML-RPC requests should go to the following URI: http://plant.blogger.com/api/RPC2

Note: This could (and, likely, will) change at some point! (Due warning will be given.)


Parameters

blogger.setTemplate takes the following parameters. All are required:
  1. appkey (string): Unique identifier/passcode of the application sending the post. (See access info.)
  2. blogid (string): Unique identifier of the blog who's template is to be returned.
  3. username (string): Login for a Blogger who has admin permission on give blog.
  4. password (string): Password for said username.
  5. template (string): The text for the new template (usually mostly HTML). Must contain opening and closing <Blogger> tags, since they're needed to publish.
  6. templateType (string): Determines which of the blog's templates will be returned. Currently, either "main" or "archiveIndex".


Examples

Here is an example of an XML-RPC call to blogger.setTemplate. Notice that <'s and >'s are escaped for transport inside XML. (Most XML-RPC libraries will do this for you, I think.)
POST /api/RPC2 HTTP/1.0 User-Agent: Java.Net Wa-Wa 2.0 Host: plant.blogger.com Content-Type: text/xml Content-length: 515 <?xml version="1.0"?> <methodCall> <methodName>blogger.setTemplate</methodName> <params> <param><value><string>C6CE3FFB3174106584CBB250C0B0519BF4E294</string></value></param> <param><value><string>744154</string></value></param> <param><value><string>ewilliams</string></value></param> <param><value><string>secret</string></value></param> <param><value><string>&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;$BlogTitle$&gt;&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;Blogger&gt;&lt;BlogDateHeader&gt;&lt;h1&gt;&lt;$BlogDateHeaderDate$&gt;&lt;/h1&gt;&lt;/BlogDateHeader&gt;&lt;$BlogItemBody$&gt;&lt;br&gt;&lt;/Blogger&gt;&lt;/body&gt;&lt;/html&gt;</string></value></param> <param><value><string>main</string></value></param> </params> </methodCall>
setTemplate returns a boolean true value upon success. Here is an example setTemplate methodResponse with no errors:
HTTP/1.1 200 OK Connection: close Content-Length: 125 Content-Type: text/xml Date: Mon, 6 Aug 20001 19:55:08 GMT Server: Java.Net Wa-Wa/Linux <?xml version="1.0"?> <methodResponse> <params> <param> <value><boolean>1</boolean></value> </param> </params> </methodResponse>

Errors

Errors are returned as an XML-RPC <methodResponse> with a <fault> item, containing a <struct> with a faultCode and a faultString, as defined by the XML-RPC spec.

Here an example response for an unsuccessful post. This error is due to an invalid templateType parameter:

HTTP/1.1 200 OK Connection: close Content-Length: 225 Content-Type: text/xml Date: Mon, 6 Aug 20001 19:55:08 GMT Server: Java.Net Wa-Wa/Linux <?xml version="1.0"?> <methodResponse> <fault> <value> <struct> <member> <name>faultCode</name> <value><int>4</int></value> </member> <member> <name>faultString</name> <value><string>java.lang.Exception: java.lang.Exception: Bad parameter: templateType must be either "main" or "archiveIndex".</string></value> </member> </struct> </value> </fault> </methodResponse>


Copyright © 2001 Pyra Labs