通过GData API和AtomEntry在Google协作平台中创建网页始终为空

时间:2013-05-16 07:49:30

标签: gdata

我使用https://code.google.com/p/gdata-samples/source/browse/trunk/sites/dotnet/SitesAPIDemo.cs中的相同GDAta API代码以C#编程在Google协作平台中创建网页。

我遇到的问题是当我创建网页时,页面在网站中成功创建,但返回的对象(newEntry)始终为null,因此我无法使用返回的信息创建任何子页面。

        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;

以前有人见过这个问题吗?

由于

赖安

1 个答案:

答案 0 :(得分:0)

我必须进入SDK的源代码才能暂时解决这个问题。这种方法似乎是个问题:

    public TEntry Insert<TEntry>(Uri feedUri, TEntry entry) where TEntry : AtomEntry
    {
        return this.Insert(feedUri, entry, null) as TEntry;
    }

我已将此更改为返回AtomEntry而不是TEntry,并且该对象不再为null:

    public AtomEntry Insert<TEntry>(Uri feedUri, TEntry entry) where TEntry : AtomEntry
    {
        return this.Insert(feedUri, entry, null);
    }