Call SAP Conversational AI API with OAuth (Postman)
- How to retrieve an OAuth token for use with SAP Conversational AI API
- How to call SAP Conversational AI API with an OAuth token
- How to set up a Postman collection to call the APIs
Prerequisites
- You have installed the Postman app.
- You have created a SAP Conversational AI chatbot, for example, as described in the tutorial Build Your First Chatbot with SAP Conversational AI.
This tutorial is a companion to the tutorial Call SAP Conversational AI API Using OAuth, which was a more sophisticated setup for calling SAP Conversational AI APIs using a Python server. Here, you will use Postman to more simply show how to retrieve an OAuth token and then call the API.
In Postman, you will set up 3 requests, and put them in a collection so they can be run together and pass arguments to each other:
-
start
: This request is a dummy request, but let’s us at the start test whether we already have an OAuth token. If yes, we skip the request for getting a token. -
get-oauth-credentials
: This request takes our chatbot credentials and calls the OAuth service to retrieve a new OAuth token. -
request
: This request is the basic SAP Conversational AI Runtime API for sending an utterance to the NLP. (We could have also used thedialog
Runtime API.)
This tutorial also shows off some of the functionality of Postman, from pre-request scripts, to tests, to setting and get environment data in order to pass between requests. It would have been simpler to use the built-in Postman OAuth authentication feature.