Show the collection IDs of IBM Cloud Watson Discovery projects using cURL

This blog post is a simple example (cheat sheet) of listing the collections for a project in Watson Discovery using cURL and the IBM Cloud Watson Discovery API V2. You can get more details in the IBM Cloud Watson Discovery API documentation.

1. Log on to IBM Cloud

ibmcloud login (-sso)

2. List the projects

OAUTHTOKEN=$(ibmcloud iam oauth-tokens | awk '{print $4;}')


curl -X GET -H "Authorization: Bearer $OAUTHTOKEN" "$DISCOVERY_URL/v2/projects?version=$VERSION"
  "projects" : [ {
    "project_id" : "YYYYY",
    "type" : "document_retrieval",
    "name" : "Sample Project 1",
    "collection_count" : 1
  }, {
    "project_id" : "ZZZZZ",
    "type" : "document_retrieval",
    "name" : "Sample Project 2",
    "collection_count" : 1
  } ]

3. List the collections

OAUTHTOKEN=$(ibmcloud iam oauth-tokens | awk '{print $4;}')


curl -X GET -H "Authorization: Bearer $OAUTHTOKEN" "$DISCOVERY_URL/v2/projects/$PROJECT_ID/collections?version=$VERSION"
  "collections" : [ {
    "name" : "Collection1",
    "collection_id" : "ZZZZZ_ZZZZZZ"
  } ]

I hope this was useful to you, and let’s see what’s next?



#curl, #watsondiscovery, #api, #watson, #ibmcloud, #ai

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at

Up ↑

%d bloggers like this: