java 可编程搜索引擎返回400请求包含无效参数

hfyxw5xn  于 2023-06-20  发布在  Java
关注(0)|答案(1)|浏览(96)

当我从Java代码、 Postman 或Web浏览器调用此URL时

URL:
https://customsearch.googleapis.com/customsearch/v1?key=AIzaSyCca5akhZ492pP08QBchz5Q4QA6kFYsBrc&cx=923a7bcc712ee431d&searchType=image&imgUrl=https://media.gq.com/photos/5a5f79d52316871dcb3c837f/master/w_1600,c_limit/Dua_Lipa_02.jpg

回复:

{
    "error": {
        "code": 400,
        "message": "Request contains an invalid argument.",
        "errors": [
            {
                "message": "Request contains an invalid argument.",
                "domain": "global",
                "reason": "badRequest"
            }
        ],
        "status": "INVALID_ARGUMENT"
    }
 }
h43kikqp

h43kikqp1#

您必须使用q参数来定义图像url而不是imageUrl

https://customsearch.googleapis.com/customsearch/v1?key=AIzaSyCca5akhZ492pP08QBchz5Q4QA6kFYsBrc&cx=923a7bcc712ee431d&searchType=image&q=https://media.gq.com/photos/5a5f79d52316871dcb3c837f/master/w_1600,c_limit/Dua_Lipa_02.jpg

相关问题