Community articleCreating a blog programmatically
Added by IBM contributorIBM on June 12, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

To create a blog, send an Atom entry document containing the blog definition to the URI specified in the collection element of the service document.



To create a blog, send an Atom entry document containing the blog definition to the URI specified in the collection element of the service document.

You must provide authentication credentials for the user who will be the owner of the blog on the request. See Authenticating requests for information about how to authenticate the request.

Input

Provide an Atom entry document that contains the blog's definition entry as the post data. The content type must be "application/atom+xml".

Output

None.

Input
Method URI Description
POST /blogs/{homepage}/api/blogs Value of the href attribute of the <collection> element that has the title My Blogs within the workspace that has the title Blogs in the user's service document.
Content Type: application/atom+xml
Sample Request:
<?xml version="1.0" encoding="UTF-8"?>

<entry 

 xmlns="http://www.w3.org/2005/Atom" 

 xmlns:app="http://www.w3.org/2007/app" 

 xmlns:snx="http://www.ibm.com/xmlns/prod/sn">

	<title type='text'>Original Title</title>

	<category term='existing-tag'/>

	<snx:timezone>America/New_York</snx:timezone>

	<snx:handle>homepage</snx:handle>

	</entry>
Name Type Optional Description
homepage
string No {homepage} represents the blog handle of the blog configured to be the home page of the Blogs application. The handle is defined when the home page blog is created by the administrator.
Name Type Optional Description
X-LConn-RunAs
string Yes The value should be in such format: userid=<user ext id>,username=<user name>,useremail=<user mail> .
This header enables impersonation and must works with Blogs admin user to authenticate request. If the user does not exists, an inactive user will be created with specified userid , username and usermail. If the user exists, username and useremail can be omitted.
eg:userid=BFB5FDCB-B0E2-408A-A351-09103D8D5527,username=xxxxxx,useremail=xxxx@cn.ibm.com
Output
Code Description
201
Indicates that the blog was successfully created. If an error occurs, this header contains one of the error codes.
400
Bad Request. Returned when no matching user record can be found.
401
Unauthorized. Returned when no authenticated user or no userid, email, or key parameter are provided on the request.
Examples
POST /blogs/homepage/api/blogs HTTP/1.1

	Authorization: Basic ...

	Host: blogs.enterprise.example.com

	Content-type: application/atom+xml

	

	<?xml version='1.0' encoding='UTF-8'?>

	<entry xmlns:snx='http://www.ibm.com/xmlns/prod/sn' xmlns='http://www.w3.org/2005/Atom'>

	<title type='text'>Original Title</title>

	<category term='existing-tag'/>

	<snx:timezone>America/New_York</snx:timezone>

	<snx:handle>atomicbilltest</snx:handle>

	</entry>


Response returned by the server
HTTP/1.1 201 Created

	Content-Type: application/atom+xml; type=entry

	Location: https://blogs.enterprise.example.com/blogs/homepage/api/blogs/

	0c0fc393-2e36-4d0e-9c9f-d4cfd10bfa70

	

	<?xml version='1.0'?>

	<entry xmlns='http://www.w3.org/2005/Atom'>

	<id>urn:lsid:ibm.com:blogs:blog-0c0fc393-2e36-4d0e-9c9f-d4cfd10bfa70</id>

	<link

	href='https://blogs.enterprise.example.com/blogs/atomicbilltest'

	rel='alternate'

	type='text/html'/>

	<link

	href='https://blogs.enterprise.example.com/blogs/homepage/api/blogs/

	0c0fc393-2e36-4d0e-9c9f-d4cfd10bfa70'

	rel='edit'

	type='application/atom+xml'/>

	<title type='text'>Original Title</title>

	<summary type='text'/>

	<updated>2008-05-20T14:09:32.296Z</updated>

	<app:edited

	xmlns:app='http://www.w3.org/2007/app'>2008-05-20T14:09:32.296Z</app:edited>

	<published>2008-05-20T14:09:32.296Z</published>

	<snx:timezone

	xmlns:snx='http://www.ibm.com/xmlns/prod/sn'>America/New_York</snx:timezone>

	<snx:locale xmlns:snx='http://www.ibm.com/xmlns/prod/sn'>en_US</snx:locale>

	<snx:handle

	xmlns:snx='http://www.ibm.com/xmlns/prod/sn'>atomicbilltest</snx:handle>

	<author>

	<name>Bill User501</name>

	<email>buser501@example.com</email>

	<snx:userid>937965j0-4f0c-1028-5a06-db07163b51b2</snx:userid>

	</author>

	<category term='existing-tag'/>

	</entry>