Export (0) Print
Expand All
Expand Minimize

IWebmasterApi.AddSite

Namespace: Microsoft.Bing.Webmaster.Api

IWebmasterApi.AddSite Method

Add new user site

Syntax

void AddSite(
string siteUrl
)

Parameters

siteUrl
Type: System.String
Site url

Remarks

If the site was already added, the method will not throw exception.

Examples

This example shows how to add site and handle errors if they occur.

namespace WebmasterApiExamples
{
    using System;
    using System.ServiceModel;

    internal class Program
    {
        private static void Main(string[] args)
        {
            var api = new WebmasterApi.WebmasterApiClient();

            try
            {
                api.AddSite("http://invalid url/");
            }
            catch (FaultException<WebmasterApi.ApiFault> fault)
            {
                Console.WriteLine("Failed to add site: {0}", fault.Message);
            }
        }
    }
}

XML request sample

POST /webmaster/api.svc/pox/AddSite?apikey=EEDECC1EA4AE341CC57365E075EBC8B6 HTTP/1.1
Content-Type: application/xml; charset=utf-8
Host: ssl.bing.com
Content-Length: 84

<AddSite xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Bing.Webmaster.Api">
<siteUrl>http://example.com</siteUrl>
</AddSite>

XML response sample

HTTP/1.1 200 OK
Content-Length: 0

JSON request sample

POST /webmaster/api.svc/json/AddSite?apikey=EEDECC1EA4AE341CC57365E075EBC8B6 HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: ssl.bing.com
Content-Length: 34


{
"siteUrl":"http:\/\/example.com"
}

JSON response sample

HTTP/1.1 200 OK
Content-Length: 10
Content-Type: application/json; charset=utf-8


{
"d":null
}

Exceptions

 

Exception Condition

Microsoft.Bing.Webmaster.Api

Thrown with error code InvalidUrl if url is not valid.

See Also

Show:
© 2014 Microsoft