Overview
The article shows the process of accessing an SAP CPI endpoint from the Postman client using Bearer Token as an Authorization mechanism.
Table Of Content
Prerequisites
- Roles to design, deploy, and monitor integration artifacts in SAP CI.
- An instance of Process Integration Runtime and Its Service Key.
Mocking a receiver
For the demo, I have created a simple integration flow to a mock receiver in SAP CPI. It uses an HTTPS sender adapter and a Content Modifier whose body is set to “This is a dummy receiver used for testing” ( This will be the response that we will be expecting at the end of the demo). The endpoint obtained by deploying the integration artifact looks as shown below.
Step 1 : Copy the end point and keep it handy to use as described in further steps.
Fetching Bearer Token
Step 2 : Open POSTMAN. Create a new request with the type POST.
Fill the Request URL with tokenurl obtained from Step 10 of this post.
Under Authorization,
Type: Basic Auth
Username: Client ID
Password: Client Secret
Client Id and Client Secret you will get when you create Process Integration Runtime Instance. ( Refer to Step 10 of this post ).
Step 3: Switch to the Body tab. Select the radio button x-www-form-urlencoded.
Key : grant_type
Value : client_credentials
Click on Send.
You will get the Token as a response body as shown in the picture below. Copy the same.
The steps to get an access token is completed. The next step is to use the token as Authorization to access SAP CPI iflow using the endpoint captured earlier.
Using the Bearer Token as Authorization
Step 4: Open a fresh request in postman. Paste the endpoint obtained in Step 1 into the request URL.
Operation: GET.
Under Authorization, Choose Type as Bearer Token. Paste the Token received in Step 3 into the Token space.
Click on Send.
You will receive the expected response. In my case, I am getting the content set in Content Modifier as a response.
This token can be used until it expires. The expiry period will be displayed when you fetch the token. Once the token expires, a new token has to be generated.
TIP: It is advised to set the Token as a variable for security reasons.
Final Verdict
In conclusion, I hope you enjoyed reading this article on “Bearer Token | Postman to SAP CPI”, If yes, then don’t forget to spread the word about it. Do send the feedback to know more about it. Signing off sudarshanpatwardhan@gmail.com