Background
Imply Polaris provides a REST API library in order to perform most common actions programmatically (admin, datasource modeling, jobs, queries, etc). For testing purpose, Postman is a great client tool, easy to setup and it will allow to execute all available POST or GET methods in few clicks, without any code.
Prerequisites
- Download the latest version of Postman
- Download the latest OpenApi.json file from Polaris API reference documentation (ensure to download the latest OpenApi version to take advantage of latest API methods available in your Postman collection)
- Setup an API Key in your Polaris account
Setup a Postman collection
- Launch Postman and Click Import button on collections tab, browse OpenAPI.json file downloaded previously
- Before importing, click show import settings then tick “Copy collections to Workspace” option, then click "Import" :
- Once Imported, rename the new added collection
- Click variables tab and set values in “initial value” column by replacing ORGANIZATION_NAME by the valid Polaris account name for all variables :
- Set a Regional URL for baseURL by replacing CLOUD_PROVIDER with actual cloud provider region name (ex : us-east-1.aws or eu-central-1.aws),
- Set a Global URL for all the other variables (https://ORGANIZATION_NAME.api.imply.io),
- Click “persist all”,
- Save collection
- Click Authorization tab, set parent authentication to Basic Auth and paste a valid API Key in Username, leave password blank :
- Important : main Polaris API Key needs to have all required permissions, or create different API Keys in Polaris, with different permissions and define each API Key in every corresponding Authorization field, at API level.
- Save collection
You are all set to execute default API methods !
Test API Methods in Postman
- Test all methods from V1 and V2 folders :
- browse the folders to find the API method to test (GET or POST)
- ensure authorization is set to "inherit Auth from parent" at the API method level :
-
- Check if parameters are required (some methods will have default parameters selected on Parameters tab that won't return any result), adjust it to send the proper API request then click “Send”.
- Example below has "search" parameter defined for v1/users method (list users from Polaris project)
Add Query method to my postman collection
The query POST method is not available in OpenAPI.json and must be created manually in the Postman collection :
- Create a sub folder under V1 folder of collection
- Create a new POST request (ensure POST is selected, not GET)
- Enter URL : ((baseUrl))/v1/query/sql
- Click Headers and then :
- deselect Accept and Content-Type
- Create 2 new keys for Accept and Content-Type with application/json value
- Save collection
Test SQL API call :
- Select the query method in V1 folder where you just created it previously,
- Click “Body” tab and type your SQL query : use format + backslash table delimiter name as below
- Test the query execution : click “Send”, response body should be returning the query result in json format
- Save collection
Generate your own code using Postman code snippet feature
This feature allows you to generate the current selected API call to various other languages.
- Click snippet button on the right panel
- Select the language in the list :
- your API call has been generated !
Python :
Curl :
Comments
0 comments
Please sign in to leave a comment.