Getting an operation's status

Several operations you request are long-running, such as product set creation via bulk import, purging a product set, and purging orphaned products. These types of requests will return a JSON with an operation ID that you can use to get the status of the operation.

For example, a batch delete (purge) request returns the following JSON:

{
"name": "projects/project-id/locations/location-id/operations/bc4e1d412863e626"
}

In this case, the operation ID is bc4e1d412863e626. The following samples show how to get the status of this operation with this ID.

REST & CMD LINE

Before using any of the request data below, make the following replacements:

  • location-id: A valid location identifier. Valid location identifiers are: us-west1, us-east1, europe-west1, and asia-east1.
  • operation-id: The ID of your operation. The ID is the last element of the name of your operation. For example:
    • operation name: projects/project-id/locations/location-id/operations/bc4e1d412863e626
    • operation id: bc4e1d412863e626

HTTP method and URL:

GET https://vision.googleapis.com/v1/locations/location-id/operations/operation-id

To send your request, choose one of these options:

curl

Execute the following command:

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://vision.googleapis.com/v1/locations/location-id/operations/operation-id

PowerShell

Execute the following command:

$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://vision.googleapis.com/v1/locations/location-id/operations/operation-id" | Select-Object -Expand Content
You should see output similar to the following for a completed product set purge operation:
{
  "name": "locations/location-id/operations/operation-id",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.vision.v1.BatchOperationMetadata",
    "state": "SUCCESSFUL",
    "submitTime": "2019-09-04T15:58:39.131591882Z",
    "endTime": "2019-09-04T15:58:43.099020580Z"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.vision.v1.PurgeProductsRequest",
    "parent": "projects/project-id/locations/location-id",
    "productSetPurgeConfig": {
      "productSetId": "project-set-id"
    },
    "force": true
  }
}

You should see output similar to the following for a completed purge orphaned products operation:

{
  "name": "locations/location-id/operations/operation-id",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.vision.v1.BatchOperationMetadata",
    "state": "SUCCESSFUL",
    "submitTime": "2019-09-04T16:08:38.278197397Z",
    "endTime": "2019-09-04T16:08:45.075778639Z"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.vision.v1.PurgeProductsRequest",
    "parent": "projects/project-id/locations/location-id",
    "deleteOrphanProducts": true,
    "force": true
  }
}
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Vision API Product Search
Need help? Visit our support page.