“给定请求参数为null或无效”使用卷曲以提交IndexNow API的URL

发布于 2025-02-07 17:47:51 字数 1880 浏览 2 评论 0原文

我尝试使用Curl通过IndexNow API将URL提交给Bing搜索引擎,但是我会发现“无效参数”错误,如何修复它?

这是PowerShell脚本

$header_host = '"Host: www.bing.com"'
$header_content = '"Content-Type: application/json; charset=utf-8"'

$url_index = 
'"https://www.bing.com/IndexNow"'

$data = '{
  "host": "xinlake.dev",
  "key": "72d80bb8d9f645ad9e246e46d336c997",
  "keyLocation": "https://xinlake.dev/72d80bb8d9f645ad9e246e46d336c997.txt",
  "urlList": [
      "https://xinlake.dev/blog/2022/05-voting-script/",
      "https://xinlake.dev/blog/2022/05-private-channel/"
      ]
}'

& curl.exe -v --http1.1 --header $header_host --header $header_content --data $data $url_index

""

这是错误日志

*   Trying 202.89.233.100:443...
* Connected to www.bing.com (202.89.233.100) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: ALPN, offering http/1.1
* schannel: ALPN, server accepted to use http/1.1
> POST /IndexNow HTTP/1.1
> Host: www.bing.com
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Content-Length: 278
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Length: 92
< Content-Type: application/json; charset=utf-8
< Expires: -1
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< X-Cache: CONFIG_NOCACHE
< Accept-CH: Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version
< X-MSEdge-Ref: Ref A: C06F23F2577843719494581907366B26 Ref B: BJ1EDGE0917 Ref C: 2022-06-15T10:20:00Z
< Date: Wed, 15 Jun 2022 10:20:00 GMT
<
{"code":"InvalidRequestParameters","message":"Given request parameters are null or invalid"}* Connection #0 to host www.bing.com left intact

I try to submit URLs to the Bing search engine through IndexNow API using cURL, but I get an "invalid parameter" error, how to fix it?

Here is the PowerShell script

$header_host = '"Host: www.bing.com"'
$header_content = '"Content-Type: application/json; charset=utf-8"'

$url_index = 
'"https://www.bing.com/IndexNow"'

$data = '{
  "host": "xinlake.dev",
  "key": "72d80bb8d9f645ad9e246e46d336c997",
  "keyLocation": "https://xinlake.dev/72d80bb8d9f645ad9e246e46d336c997.txt",
  "urlList": [
      "https://xinlake.dev/blog/2022/05-voting-script/",
      "https://xinlake.dev/blog/2022/05-private-channel/"
      ]
}'

& curl.exe -v --http1.1 --header $header_host --header $header_content --data $data $url_index

""

Here is the error log

*   Trying 202.89.233.100:443...
* Connected to www.bing.com (202.89.233.100) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: ALPN, offering http/1.1
* schannel: ALPN, server accepted to use http/1.1
> POST /IndexNow HTTP/1.1
> Host: www.bing.com
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Content-Length: 278
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Length: 92
< Content-Type: application/json; charset=utf-8
< Expires: -1
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< X-Cache: CONFIG_NOCACHE
< Accept-CH: Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version
< X-MSEdge-Ref: Ref A: C06F23F2577843719494581907366B26 Ref B: BJ1EDGE0917 Ref C: 2022-06-15T10:20:00Z
< Date: Wed, 15 Jun 2022 10:20:00 GMT
<
{"code":"InvalidRequestParameters","message":"Given request parameters are null or invalid"}* Connection #0 to host www.bing.com left intact

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三月梨花 2025-02-14 17:47:51

谢谢,我已经通过发布JSON文件解决了这一点。

脚本更改

$data = '"path to the json file"'
& curl.exe -v --http1.1 --header $header_host --header $header_content --data @$data $url_index

JSON文件

{
    "host": "xinlake.dev",
    "key": "72d80bb8d9f645ad9e246e46d336c997",
    "keyLocation": "https://www.xinlake.dev/72d80bb8d9f645ad9e246e46d336c997.txt",
    "urlList": [
        "https://www.xinlake.dev/blog/2022/05-voting-script/",
        "https://www.xinlake.dev/blog/2022/05-private-channel/"
    ]
}

请求和响应

*   Trying 202.89.233.101:443...
* Connected to www.bing.com (202.89.233.101) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: ALPN, offering http/1.1
* schannel: ALPN, server accepted to use http/1.1
> POST /IndexNow HTTP/1.1
> Host: www.bing.com
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Content-Length: 302
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: -1
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< X-Cache: CONFIG_NOCACHE
< Accept-CH: Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version
< X-MSEdge-Ref: Ref A: C9107410449C4D1A837A53C5CB1D392C Ref B: BJ1EDGE0416 Ref C: 2022-06-15T14:11:21Z
< Date: Wed, 15 Jun 2022 14:11:21 GMT
< Content-Length: 0
< 
* Connection #0 to host www.bing.com left intact

Thanks, I have solved this by posting a JSON file.

Script changes

$data = '"path to the json file"'
& curl.exe -v --http1.1 --header $header_host --header $header_content --data @$data $url_index

JSON file

{
    "host": "xinlake.dev",
    "key": "72d80bb8d9f645ad9e246e46d336c997",
    "keyLocation": "https://www.xinlake.dev/72d80bb8d9f645ad9e246e46d336c997.txt",
    "urlList": [
        "https://www.xinlake.dev/blog/2022/05-voting-script/",
        "https://www.xinlake.dev/blog/2022/05-private-channel/"
    ]
}

Request and response

*   Trying 202.89.233.101:443...
* Connected to www.bing.com (202.89.233.101) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: ALPN, offering http/1.1
* schannel: ALPN, server accepted to use http/1.1
> POST /IndexNow HTTP/1.1
> Host: www.bing.com
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Type: application/json; charset=utf-8
> Content-Length: 302
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: -1
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< X-Cache: CONFIG_NOCACHE
< Accept-CH: Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version
< X-MSEdge-Ref: Ref A: C9107410449C4D1A837A53C5CB1D392C Ref B: BJ1EDGE0416 Ref C: 2022-06-15T14:11:21Z
< Date: Wed, 15 Jun 2022 14:11:21 GMT
< Content-Length: 0
< 
* Connection #0 to host www.bing.com left intact
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文