Skip to Content

Set Up Postman Client for SAP AI Core

test
0 %
Set Up Postman Client for SAP AI Core
Details

Set Up Postman Client for SAP AI Core

Requires Customer/Partner License
October 11, 2021
Created by
October 10, 2021
Get Postman Collections and environment variables for SAP AI Core. Learn to generate OAuth token to authorize API calls.

You will learn

  • How to use Postman environment variable
  • How to authorize Postman API calls with OAuth

QR code

Step 1: Set up Postman collections for SAP AI Core API

Download the following files

File Name Download LINK
AI-API_postman_collection.json Download Here
AI-API_postman_environment.json Download Here

Open Postman.

Click on the Import button.

postman import

Click on Upload Files and browse-open the AI-API_postman_collection.json file.

postman browse

Then click Import.

postman import

You will see all the API endpoints used for SAP AI Core API calls gets listed under Collections > AI-API in Postman

postman collection

.

Follow the same steps and import AI-API_postman_environment.json to Postman

env import
Log on to answer question
Step 2: Set Postman environment variables for SAP AI Core API

To use environment variables for your API calls.

  1. Click the drop-down on the top right corner
  2. select aicore-ai-env ( imported in previous step )

If any part of your API call, whether ** **, Headers, Body, Authorization use environment variable, it is enclosed within *double braces. Example:{{clientid}}

env select
Log on to answer question
Step 3: Edit value of Postman environment variable

To quick-edit value of environment variable.

  1. Click on the eye button on top right corner
  2. Click on the pencil under the column CURRENT VALUE.
  3. Type the value in the field.
  4. Click anywhere outside the popup-box. It would be automatically be saved.
env set

Test yourself

In the given image, the API endpoint uses a environment variable.

endpoint example
Type the environment variable referred in the image above.
×
Step 4: Set SAP AI Core service keys as Postman Environment variables

Follow the provisioning steps to get an SAP AI Core service instance key from SAP BTP cockpit.

If you already have an SAP AI Core service instance you can get the service key from your SAP BTP cockpit:
SAP BTP cockpit > SAP BTP subaccount > Instances and Subscriptions > Instances > Credentials

The service key file contents should look similar like this:

{
  "clientid": "ss-2222-aaa-4444-888-8555!bbb|aicore!bbb",
  "appname": "2222-aaa-4444-888-8555!bbb|aicore!bbb",
  "identityzone": "tutorial",
  "identityzoneid": "11111-dddd-444-888-888888",
  "clientsecret": "8MQWERTy=",
  "serviceurls": {
  "ML_API_URL": "https://api.ai.prod.us-east-1.aws.ml.hana.ondemand.com"
  },
  "url": "https://tutorial.authentication.us10.hana.ondemand.com"
}

CAUTION Set your own values, the values presented are for understanding.

Edit your Postman environment variables w.r.t. to the SAP AI Core service key JSON obtained, use the VARIABLE association mentioned below.

Postman Environment Variable KEY in SERVICE KEY (paste their values)
auth_url url
client_id clientid
client_secret clientsecret
apiurl ML_API_URL
env variables
Log on to answer question
Step 5: Generate OAuth token for API call

OAuth token are similar to your signature, adding credibility to API calls.

To generate OAuth token.

COLLECTIONS > GET Auth token

Endpoint

{{auth_url}}/oauth/token?grant_type=client_credentials

Image

SEND

Response

Image

The OAuth token will be automatically updated in your environment variables under token. ( If not, set it manually, value from response. )

AUTH token environment
  • OAuth token are used in any other API calls, under Authorization.
  • The OAuth token hold valid for a certain duration (~ 2-3 hours). You will need to generate OAuth token again if you encounter error stating JWT expired.
Log on to answer question
Step 6: Test yourself

The OAuth token will be used in Authorization for any other API calls. Lets locate.

  1. Click on any other API Call. Go to Authorization tab.

    API Repository Authorization tab

    If Type: Inherit auth from parent. Locate what Type parent(collection) is using.

  2. You will find the Type Bearer Token and Token value set to environment variable token.

    API Authorization Type
What Authorization Type was used by API: Get Auth Token
×

Next Steps

Back to top