I need to verify the ownership of website using "metatag" in Webmaster Tools. I am using Google Webmaster Tool API in Vb.net. Following are the code logic.
Dim client As New WebClient
Try
Dim query As String
client.Headers.Add("Authorization: GoogleLogin auth=" + _auth)
client.Headers.Add("GData-Version: 2")
client.Headers.Add("Content-Type", "application/atom+xml")
query = "<atom:entry xmlns:atom=""http://www.w3.org/2005/Atom"" " + _
"xmlns:wt=""http://schemas.google.com/webmasters/tools/2007""> " + _
"<atom:id>https://www.google.com/webmasters/tools/feeds/sites/http%3A%2F%2Ftestwebsite2.demos.classicinformatics.com%2F</atom:id> " + _
"<atom:category scheme='http://schemas.google.com/g/2005#kind' " + _
"term='http://schemas.google.com/webmasters/tools/2007#site-info'/> " + _
"<wt:verification-method type=""metatag"" in-use=""true""/> " + _
"</atom:entry>"
Dim response = client.UploadString("https://www.google.com/webmasters/tools/feeds/sites/http%3A%2F%2Ftestwebsite2.demos.classicinformatics.com%2F", _
"PUT", query)
Catch ex As WebException
End Try
In above code, after uploading API string, I am getting 400 Bad Request error, while If successful, the response should be Sites feed with each entry updated and the "verified" element set to "true".