Aşağıda kendi kullandığım kodu kullanabilirsiniz, api alanından alacağınız json dosyanız ile .py dosyanızı aynı klasöre ekleyin ve python dosyasını çalıştırın. Yine search console alanından izin v.s vermeniz gerekli tüm işlemler aynı.
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
import json
SCOPES = [ "https://www.googleapis.com/auth/indexing" ]
ENDPOINT = "https://indexing.googleapis.com/v3/urlNotifications:publish"
JSON_KEY_FILE = "kendidosyaniz.json"
credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE, scopes=SCOPES)
http = credentials.authorize(httplib2.Http())
content = """{
"url": "https://www.siteniz.com",
"type": "URL_UPDATED"
}"""
response, content = http.request(ENDPOINT, method="POST", body=content)
print("Response Status:", response.status)
print("Response Content:", content.decode('utf-8'))
try:
json_content = json.loads(content)
print("JSON Content:", json.dumps(json_content, indent=2))
except ValueError as e:
print("Error parsing JSON:", e)