Reputation: 113
I am using Google Blogger API to create posts programmatically in a blog I created. I am using the code below to try and create a new post but it keeps giving me the error:
*Execution of request failed: https://galeajean.blogspot.com/ ---> System.Net.WebException: The remote server returned an error: (405) Method Not Allowed.*
the code I am using is:
Service service = new Service("blogger", "blogger-example-1");
service.Credentials = new GDataCredentials(actualusername, actualpassword);
GDataGAuthRequestFactory factory = (GDataGAuthRequestFactory)service.RequestFactory;
factory.AccountType = "GOOGLE";
Uri blogPostUri = new Uri("http://galeajean.blogspot.com/");
AtomEntry createdEntry = PostNewEntry(service, blogPostUri);
static AtomEntry PostNewEntry(Service service, Uri blogPostUri)
{
Console.WriteLine("\nPublishing a blog post");
AtomEntry createdEntry = null;
if (blogPostUri != null)
{
// construct the new entry
AtomEntry newPost = new AtomEntry();
newPost.Title.Text = "Marriage!";
newPost.Content = new AtomContent();
newPost.Content.Content = "<div xmlns='http://www.w3.org/1999/xhtml'>" +
"<p>Mr. Darcy has <em>proposed marriage</em> to me!</p>" +
"<p>He is the last man on earth I would ever desire to marry.</p>" +
"<p>Whatever shall I do?</p>" +
"</div>";
newPost.Content.Type = "xhtml";
newPost.Authors.Add(new AtomPerson());
newPost.Authors[0].Name = "Elizabeth Bennet";
newPost.Authors[0].Email = "[email protected]";
createdEntry = service.Insert(blogPostUri, newPost);
}
return createdEntry;
}
Any help would be greatly appreciated guys....thanks in advance ;)
Upvotes: 0
Views: 735
Reputation: 34
ok,i gt the prblm... problem is in your blog blogPostUri.. this should be.
Uri blogPostUri = new Uri("http://www.blogger.com/feeds/" + blogID + "/posts/default");
Upvotes: 1
Reputation: 34
remove the line
newPost.Content.Type = "xhtml";
thn check again...because it may be possible that the content type you posting not meet the stndrds of blogger policies...it may help...
Upvotes: 0