how can i insert a new sitemap with google gdata api? it returns 400 bad request

Posted by wingoo on Stack Overflow See other posts from Stack Overflow or by wingoo
Published on 2010-05-02T16:43:43Z Indexed on 2010/05/02 16:47 UTC
Read the original article Hit count: 373

Filed under:
|
|
|
|

i try to insert a new sitemap to google using api, but i can't do it successful-_- this is the method

        var fullDomainUrl = "http://www.example.com/";
        var entry = new SitemapsEntry();
        entry.Id = new AtomId(fullDomainUrl + "sitemap.xml");
        entry.Categories.Add(new AtomCategory("http://schemas.google.com/webmasters/tools/2007#site-info", new AtomUri("http://schemas.google.com/g/2005#kind")));
        entry.SitemapType = "WEB";
        myService.Insert(new Uri(string.Format("https://www.google.com/webmasters/tools/feeds/{0}/sitemaps/", HttpUtility.UrlEncode(fullDomainUrl))), entry);

this will retuen a 400 bad request
and i try another method

var settings = new RequestSettings("TesterApp1", domain.GoogleAuthToken, CommonService.GetRsaPrivateKey(Context));
            var request = new WebmasterToolsRequest(settings);
            var sitemap = new Sitemap();
            sitemap.Id = fullDomainUrl + "sitemap.xml";
            sitemap.Categories.Add(new AtomCategory("http://schemas.google.com/webmasters/tools/2007#site-info", new AtomUri("http://schemas.google.com/g/2005#kind")));
            sitemap.SitemapType = "WEB";
            //request.AddSitemap(fullDomainUrl, sitemap);
            request.Insert(new Uri(string.Format("https://www.google.com/webmasters/tools/feeds/{0}/sitemaps/", HttpUtility.UrlEncode(fullDomainUrl))), sitemap);

this also return a 400 bad request
and then i try to use HttpWebRequest to post the atom to google,but it also return a 400 bad request(???")
i can insert/update site successful,but can;t insert a new sitemap..
does any can give a right code with .net?

© Stack Overflow or respective owner

Related posts about google

Related posts about gdata