首页 > 解决方案 > 客户端错误:`POST { "error": { "code": 400, "message": "One of content, or gcs_content_uri must be set.", "status": "INVALID (truncated

问题描述

我尝试使用 GuzzleHttp\Client 从 laravel 调用 post api。但是我们尝试以不同的方式 tp 传递 api 密钥,但如果我在 url 中附加 API 密钥则不会得到输出,然后我得到这个结果。

//intiate client
$client = new \GuzzleHttp\Client([
                'base_uri' => 'https://language.googleapis.com/',
            ]);

//api call for get data entitiwise

$response = $client->request('POST','/v1/documents:analyzeEntities?key=' . $apiKey, $finalData);

标签: laravel-5google-cloud-platformgoogle-natural-language

解决方案


There is no problem with your api key. You have to set either 'content' or 'gcsContentUri' in your request: https://cloud.google.com/natural-language/docs/reference/rest/v1/documents#Document


推荐阅读