Step

Generate API Key

Host your API key

  • Create a file in Directory of you website

  • will look like this

    1
    
    d06c191380a74c08a8ef46d9a32e3eec.txt
    
  • Update website after adding to root of directory

Send Request via C#

Requirement

  • VS Code
  • PolyGlot Notebook Extension
  • .Net Sdk Installed
  • if Not Please Follow Installtion step from here will Create Demo for that process.

Open VS Code

  • Create New Folder
  • Inside Folder Create two File
    • data.txt
    • bing.ipynb Search Bar New Project
  • In data.txt File Fill all the URL in Follwing Fasion Search Bar New Project

Code in bing.ipynb

  • Make Sure You Selected .Net Interactive

  • Fill these data for Importing Library Fron Nuget Package

    1
    
    #r "nuget: Newtonsoft.Json, 13.0.3"
    
  • Click on Create next Cell

  • Importing relevant namespace which is used

1
2
3
4
5
6
using System;
using System.Net.Http;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization; 
using Newtonsoft.Json;
  • Creating class for passing credential
1
2
3
4
5
6
7
public class Data
{
    public string host {get;set;}
    public string key {get;set;}
    public string keyLocation {get;set;}
    public List<string> urlList {get;set;}
}
  • Replace data.host value with your absolute website url
  • Replace data.key value with your generated key
  • data.keyLocation value with you generated value
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var ls = string.Join(",",File.ReadAllLines("data.txt"));
var httpClient = new HttpClient();
var data = new Data();
data.host =  "www.domain.com";
data.key = "xxxx";
data.keyLocation ="https://www.domain.com/xxxx.txt";
data.urlList = File.ReadAllLines("data.txt").ToList();


var jsondata = JsonConvert.SerializeObject(data);

var senddata = new StringContent(jsondata,Encoding.UTF8,"application/json");

var response = await httpClient.PostAsync("https://api.indexnow.org/indexnow", senddata);


if (response.IsSuccessStatusCode)
{
    Console.WriteLine("Request successful");
    var responseContent = await response.Content.ReadAsStringAsync();
    Console.WriteLine(responseContent);
}
else
{
    Console.WriteLine($"Request failed with status code: {response.StatusCode}");
}

Click On Run All on to of VS Code. Wait for process to Finish