I am trying to test out the vision API and have uploaded some images to Google cloud storage and have created a browser app that requests the cloud api to process them.
I have a client_id file that I downloaded from the Google developers console. This has a client_id value that I am using as my api key.
I make a request to
https://content-vision.googleapis.com/v1/images:annotate?alt=json&key=414712345643-cln7htsuv78jr9i64v8v7g6cnhm3ccff.apps.googleusercontent.com
(api key altered)
and post the request:
{
"requests": [
{
"image": {
"source": {
"gcsImageUri": "https:\/\/console.cloud.google.com\/m\/cloudstorage\/b\/estoril_test\/o\/AI4C3160.JPG"
}
},
"features": [
{
"type": "LABEL_DETECTION",
"maxResults": 1
}
]
}
]
}
but I get an error:
{
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/414754136843/apiui/credential"
}
]
}
]
}
}
I have authorized that api key for the cloud vision api so what am I doing wrong? I did try the curl example in the demo but I keep getting
Protocol https not supported or disabled in libcurl
I tried adding double quotes as some research suggested I should but still no luck.
For the "API key not valid" issue, it appears that you are using a Server key, but you need to use a browser key. The Vision API Getting Started page has detailed screenshots, as well as a curl example. The second issue you are likely to encounter is that the gcsImageUri is the incorrect format.
Again, use the hamburger menu to get the nav bar, and select the the API manager, and "Dashboard" from the sub-menu. Click "Enable API" at the top. On the next screen, find the Cloud Vision API, and select it. Then click "Enable".
For the "API key not valid" issue, it appears that you are using a Server key, but you need to use a browser key. The Vision API Getting Started page has detailed screenshots, as well as a curl example.
The second issue you are likely to encounter is that the gcsImageUri
is the incorrect format. According to the Vision API reference docs the image URI must be in the form "gs://bucket_name/object_name", so in your case: something like: "gs://storil_test/AI4C3160.JPG"
Another problem that can be encountered with a KEY not working is that a particular service has not been added to the project you are trying to work with. That will give this same response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With