Skip to content

Snowflake-Labs/snowflake-rest-postman-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snowflake REST API Demo with Postman

The demo companion code for Snowflake REST API demo with Postman.

As part of this demo we will cover few APIs:

  • Warehouses
  • Tables
  • Roles
  • Grants
  • Users

Pre-requisites

Demo Sources

git clone https://github.com/Snowflake-Labs/snowflake-rest-postman-demo.git

Import Postman Collections and Environment

Use the Postman Import feature to import the collections from $DEMO_HOME/collections folder and environment tutorial from $DEMO_HOME/environments folder.

Important

Ensure to set the tutorial as DEFAULT environment in postman

Environment Setup

Snowflake

Ensure that you have Snowflake account available and configured to be used with Snowflake CLI.

Run the following command to ensure all set with respect to Snowflake connection,

snow connection test -c <your connection name>

If you have not configured your Snowflake session, please refer to this documentation.

Tip

It is very convinient to have a variable named SNOWFLAKE_DEFAULT_CONNECTION_NAME configured on your shell. It helps snow cli to use a default connection without -c parameter

To be able to generate JWT token you need to have your connection configured with Key-Pair authentication. Check the documentation on how to configure KeyPair auth with the Snowflake CLI.

Important

Please configure your Key-Pair in encrypted mode with a private key passphrase

export SNOWFLAKE_DEFAULT_CONNECTION_NAME=trial
export PRIVATE_KEY_PASSPHRASE=<your private key passphrase>

Ensure you have configured all and successful run the following command to generate JWT token,

snow generate-jwt

Postman

The following information are need to configure the following variables as part of Postman's tutorial environment:

Tip

If you have tools like jq then you can build your base url like

snow connection test --format json | jq -r '"https://" + .Host'

AND snowflake_username like

snow connection test  --format json | jq -r '.User'

Both these commands use Snowflake connectio fomr $SNOWFLAKE_DEFAULT_CONNECTION_NAME

All requests are configured to have the following headers,

  • Content-Type is always application/json
  • x-snowflake-authorization-token-type is set to use the variable snowflake_auth_type from the environment which is by default set to KEYPAIR_JWT

Running Collections

Now you are all set to run the collections using Postman. For demonstration purpose there is some data that you can use API inside config folder. Please check https://learning.postman.com/docs/collections/running-collections/working-with-data-files/ to see how to use the data with Postman.

There are few SQL statements in check.sql that you can try before and after the collection run to make sure all works.

References

About

Snowflake REST API with Postman demo companion code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published