Use this article to learn how to use Postman to test the Workflow REST API using an OAuth token.
Step 1: Add the K2 API Delegated Permission to your Azure AAD App
Follow the steps in Configure AAD and K2 Services for Inbound OAuth to add the K2 API permission to your Azure AD App. This is necessary for K2 to authorize the OAuth request from your AAD identity.
Step 2: Enable the Workflow REST API and get the Swagger link
In this step, you enable the Workflow REST API and get the URL to the Swagger (OpenAPI) file for the service.
- Open K2 Management.
- Navigate to Integration > APIs > Workflow REST. Note that you can also call the SmartObject OData API with an inbound OAuth token.
- Enable the Workflow API and click the open link of the Swagger URL.
- When the new browser window opens, copy the link at the top of the window.
Step 3: Import Swagger into Postman
In this step, you import the Swagger file into Postman.
- Open Postman.
- Click Import in the upper left.
- On the Import dialog, click Import From Link and paste in the Swagger file link as shown here:
Navigate to Workflows > Get Workflows.
Parameters are automatically added to the request. Keep in mind that not all parameters are required. For more information see the Swagger definition. For this Get Workflows method, use the value Startable for the type.
Step 4: Acquire an OAuth Token and Test the API
In this step, you configure Postman to retrieve an OAuth token to access the K2 Workflow REST API.
- Click Authorization and then Get New Access Token.
- On the Get New Access Token dialog, fill in the values for your environment:
|Callback URL (the reply_uri)
|Access Token URL
||Your app’s Client ID (Application ID), such as 433d08a8-e5c8-4784-aeb0-b0ac24af6c1c
||Your app’s secret, such as k77OemePvRUURLaXBCTRUaieDNXgaaLoiohW/Md0X5M=
In the Auth URL field, it is necessary to add ?resource=https://api.k2.com/ to the end of the string in order for Azure to send K2 the correct token values. This value does not have to be https://api.k2.com but it must match the audience value of the Bearer Token OAuth resource. You can see this in K2 Management > Authentication > OAuth > OAuth Resources.
An easy way to find the auth URLs and Tenant ID of your Azure tenant is to use the following OpenID URL, replacing [Azure Tenant] with your full tenant name such as k2example.onmicrosoft.com: https://login.microsoftonline.com/[Azure Tenant]/.well-known/openid-configuration
- Click Request Token and log in using your AAD identity.
- Scroll down to the bottom of the Manage Access Tokens dialog and click Use Token.
To see encoded information about your access token, go to jwt.ms
, paste your token value, and decode it.
- Click Send and note the JSON payload in the Body of the response.
Use these links for learning more about OAuth in the K2 platform and code for calling K2 services.