Making your first request

Kindly read the Authentication page to know about the host url, token generation, token permissions and scopes before moving to further sections.

Let's walk through some sample requests to get familiar with the general usage of the developer-ready endpoints!

Attention

For the sake of the example, we shall demonstrate the usage of the /createcollection developer-ready endpoint. To find out more about a specific endpoint's fields and usage, please refer to its API reference page!

Case 1. Using a user-scoped token

Step 0: Ensuring accurate token information

Token details expected:

  • The permissions for the token should be set to USER , the user email should be set to a valid user email (say, john.doe@yourdomain.com ) while creating the token.
  • The scope list for the token should contain the COLLECTIONS scope.

Step 1: Making the request

  • Use the following cURL command to create a collection.
Copy
Copied
curl -X POST https://customer-be.glean.com/rest/api/v1/createcollection \
-H 'Authorization: Bearer <token>' \
-d '{
     "name": "Sample Collection - '$(date +"%Y-%m-%d %H:%M:%S")'",
     "description": "A brief summary of the collection\'s contents."
}'
Warning

If you get a response with a status code other that 200, use the error response to figure out what might have gone wrong. For example, the token may have expired, causing the request to fail.

Step 2: Ta-Da!

  • Go to the Collections tab to verify that your collection has been created! Don't forget to delete the test collection once you're done!
Note

As seen in the screenshot below, the email provided was identical to that of the user-logged in. If that is not the case, the Created By field will reflect the appropriate creator, based on the inferred email.

collection_creation_success.png

Case 2: Using a global token

Step 0: Ensuring accurate token information

Token details expected:

  • The permissions for the token should be set to GLOBAL , the user email would not be set.
  • The scope list for the token should contain the COLLECTIONS scope.

Step 1: Making the request

  • Use the following cURL command to create a collection
  • Replace <User email> in the X-Scio-Actas header with a valid email address of a user on whose behalf the request is intended to be made.
Copy
Copied
curl -X POST https://customer-be.glean.com/rest/api/v1/createcollection \
-H 'Authorization: Bearer <token>' \
-H 'X-Scio-Actas: <User email>' \
-d '{
     "name": "Sample Collection - '$(date +"%Y-%m-%d %H:%M:%S")'",
     "description": "A brief summary of the collection\'s contents."
}'
Warning

If you get a response with a status code other that 200, use the error response to figure out what might have gone wrong. For example, the token may have expired, causing the request to fail.

Step 2: Ta-Da!

  • Go to the Collections tab to verify that your collection has been created! Don't forget to delete the test collection once you're done!
Note

As seen in the screenshot below, the email provided was identical to that of the user-logged in. If that is not the case, the Created By field will reflect the appropriate creator, based on the inferred email.

collection_creation_success.png