Support Note KB0398017
Email
Setup Postman for Easy Testing of SAP Ariba Open API
Postman Overview

Postman is a standalone software available to download from the internet. It is not created by SAP or SAP Ariba. It allows a user to send http and https requests to servers as a way to test the functionality of different APIs around the web. This is why it is useful to us when testing the functionality of the Open API. Below I will detail the setup that I have found useful for sending requests easily.

Please note that I have the dark theme enabled in my copy of Postman, so my screenshots may look a little different. Don't be alarmed if your copy has a different appearance.

Step One - Set Up An Environment

We want to start by setting up an Environment. An Environment in Postman lets you set up variables that can be accessed across your different requests. This is handy because then you won't have to manually copy over your authorization token every time it's generated, or your realm name, api key, and any other information that is accessed in many requests.

To do this, click on the Gear in the top right of Postman:

Click Add on the popup that appears and name your environment:

This window also allows you to define the variables that can be accessed from anywhere that you have this environment selected. I would recommend creating variables for accesstoken, realm, baseurl, and base64encoded string as I have below. In a below section I will walk through how to get the accesstoken to automatically populate when you run the request to generate it, but for now just fill it in with your latest (or leave it blank).

 

Accessing the variables

 

Now that you have the variables set up in your environment, first make sure that your environment is selected - the drop down menu next to the gear symbol shows your currently selected environment.

Now, whenever you want to access the information stored in the variable, just put the name of it in double curly braces. For example, to get your access token to populate in a request, just put {{accesstoken}}. See the screenshot of an example request for approvable information below:

Postman converts this into the below cURL:

curl -X GET \
  'https://openapi.ariba.com/api/approval/v1/prod/invoices/INV201704111948-2053?realm=aribasupportsg' \
  -H 'APIKEY: [redacted]' \
  -H 'Authorization: Bearer [redacted]' \
  -H 'Cache-Control: no-cache' \
  -H 'Postman-Token: 0424c991-2a5b-496d-86a8-0a00215156e1'

 

How to get the access token to save as an environment variable

Below is a screenshot of my setup to generate an oauth token:

and my curl:

curl -X POST \
  https://api.ariba.com/v2/oauth/token \
  -H 'Authorization: Basic [redacted]' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Postman-Token: 418f7815-13e1-4f39-846b-a26b8ca73f35' \
  -d grant_type=openapi_2lo
 
Once this is completed, click the Tests tab. You'll notice that my screenshot has a green circle next to it. Once here, simply copy the below code, which will save the json access_token as environmentvariable accesstoken:
 
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("accesstoken", jsonData.access_token);
 
Bonus Information

If you have to access different realms for your testing, you can have multiple environments set up so that you can use the same requests on multiple realms easily.

 
 

Applies To

Purchasing

Terms of Use  |  Copyright  |  Security Disclosure  |  Privacy