POST requests to Bing Webmaster API always gives NotAuthorized

825 views Asked by At

I'm trying to programmatically submit sitemap index files to Bing via HTTP POST requests. I followed the JSON request example from their documentation page.

Here is the request I'm trying to make in cURL (I replaced the site url and apikey):

curl -XPOST -H 'Host: ssl.bing.com' -H "Content-type: application/json" -d '{
"siteUrl":"https:\/\/www.example.com",
"feedUrl":"https:\/\/www.example.com\/Sitemaps\/SitemapIndex--stuff--01.xml"
}' 'https://bing.com/webmaster/api.svc/json/SubmitFeed?apikey=MY_KEY'

The response looks like this:

{
    "ErrorCode": 14,
    "Message": "ERROR!!! NotAuthorized"
}

The api key is generated from the Bing webmaster ui portal. My user has administrator rights. Adding a Content-Length header did not help.

GET requests work alright and I can retrieve feed or traffic information.

In the Bing webmaster portal UI page I can submit sitemap files with no problem.

I've searched the web for this before asking and I could not find anything relevant. Has anyone encountered this problem also? Probably I'm missing something and I would appreciate some advice.

1

There are 1 answers

0
Andrey Pristupa On

This error appears when:

1 - Verified URL in the webmaster does not match siteUrl in your request

Example: webmaster - https://example.com/ request - https://example.com/home

2 - URL's in your urlList does not match siteUrl pattern

Example: siteUrl - https://example.com/home/ url - https://example.com/about-us.html