I'm using the same GDAta API code from https://code.google.com/p/gdata-samples/source/browse/trunk/sites/dotnet/SitesAPIDemo.cs to programatically create web pages in Google Sites in C#.
The problem I'm getting is when I create a Web Page the page is created successfully in the site but the returned object (newEntry) is always null so I can't create any child pages with the returned information.
SiteEntry entry = new SiteEntry();
AtomCategory category = new AtomCategory(SitesService.WEBPAGE_TERM, SitesService.KIND_SCHEME);
category.Label = "webpage";
entry.Categories.Add(category);
entry.Title.Text = title;
entry.Content.Type = "xhtml";
entry.Content.Content = html;
entry.ExtensionElements.Add(makePageNameExtension(pageName));
AtomEntry newEntry = null;
try
{
//the newEntry below is always returned as null
newEntry = service.Insert(new Uri(makeFeedUri("content")), entry);
}
catch (GDataRequestException e)
{
Console.WriteLine(e.ResponseString);
}
return newEntry;
Has anybody seen this problem before?
Thanks
Ryan
I've had to get into the source code of the SDK to fix this temporarily. This method seems to be the problem:
public TEntry Insert<TEntry>(Uri feedUri, TEntry entry) where TEntry : AtomEntry
{
return this.Insert(feedUri, entry, null) as TEntry;
}
I have changed this to return an AtomEntry rather than a TEntry and the object is no longer null:
public AtomEntry Insert<TEntry>(Uri feedUri, TEntry entry) where TEntry : AtomEntry
{
return this.Insert(feedUri, entry, null);
}