IWebmasterApi.AddSite(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Add new user site
public:
void AddSite(System::String ^ siteUrl);
[System.ServiceModel.FaultContract(typeof(Microsoft.Bing.Webmaster.Api.Interfaces.ApiFault))]
[System.ServiceModel.OperationContract]
[System.ServiceModel.Web.WebInvoke(BodyStyle=System.ServiceModel.Web.WebMessageBodyStyle.WrappedRequest, Method="POST")]
public void AddSite (string siteUrl);
abstract member AddSite : string -> unit
Public Sub AddSite (siteUrl As String)
Parameters
- siteUrl
- String
- Attributes
Exceptions
Thrown with error code ErrorCode if url is not valid.
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=sampleapikeyedecc1ea4ae341cc8b6 HTTP/1.1
Content-Type: application/xml; charset=utf-8
Host: ssl.bing.com
<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=sampleapikeyedecc1ea4ae341cc8b6 HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: ssl.bing.com
{
"siteUrl":"http://example.com"
}
JSON response sample
HTTP/1.1 200 OK
Content-Length: 10
Content-Type: application/json; charset=utf-8
{
"d":null
}
Remarks
If the site was already added, the method will not throw exception.