Some days ago I have been struggling with implementing IndexNow, I did almost exactly as mentioned here in this tutorial https://www.bing.com/indexnow/getstarted#implementation, but it did not work.
The payload was correct and the data and the endpoint was right but I got bad request, I had no clue what to fix.
The error:
{\"code\":\"InvalidRequestParameters\",\"message\":\"Given request parameters are null or invalid\"}
After finding https://stackoverflow.com/questions/72629964/given-request-parameters-are-null-or-invalid-when-using-curl-to-submit-urls-wi on stackoverflow I changed endpoint to "https://www.bing.com/IndexNow" I finally found the cause.
IndexNow submission failed with status LengthRequired.
The whole issue has been the http version all along which I never thought of as I have never had any reasons before to set that manually.
The solution to fix the issue:
var request = new HttpRequestMessage(HttpMethod.Post, endpoint)
{
Version = HttpVersion.Version11,
VersionPolicy = HttpVersionPolicy.RequestVersionExact,
Content = new StringContent(
JsonSerializer.Serialize(payload, JsonSerializerOptions.Web),
Encoding.UTF8,
"application/json")
};
I hope it help someone who may struggle with the same issue.
A small note, the correct endpoint is https://api.indexnow.org/indexnow.
Top comments (0)