How to fix "unexpected keyword argument body error"
The submit
method doesn't take a body
parameter; instead, you should directly include the information in the siteUrl
and feedpath
parameters.
Here's How to correct that in the submit_sitemap
function:
def submit_sitemap(credentials, property_uri, sitemap_url):
if credentials:
try:
service = build('webmasters', 'v3', credentials=credentials)
request = service.sitemaps().submit(
siteUrl=property_uri,
feedpath=sitemap_url
)
response = request.execute()
print(response)
except Exception as e:
print(f"Sitemap submission failed: {e}")
Now, the submit_sitemap
function correctly uses siteUrl
and feedpath
without the body
parameter. Save the changes and try running the script again.