Hi, welcome back to our video tutorial series about developing applications with SAP Ariba
APIs.
I am Denys van Kempen from the Digital Partner Engineering team of SAP’s global partner
organisation.
In the first video of this series, we explained how to get started, where to sign up, how
the developer portal works, and where to find the documentation.
For this video, I assume you are familiar with these topics, so we can dive straight
into our APIs.
In the first couple of videos, we will be looking at the analytics API.
Time of recording is November 2019.
For updates, please check the SAP Ariba API playlist on our YouTube channel.
OK Let’s first connect
developer.ariba.com/api I will be connecting to the United States
Data Center for this video but for the analytics API, you can connect to any of the other data
centres as well.
Here, for example, let’s take Russia.
In the Discover menu on the header
We find all the APIs available for the upstream and downstream solutions, catalog, procurement,
sourcing, etc.
The only difference, concerns the Ariba Network APIs.
So, when we connect to the United States data center
I will be using single sign-on.
Then we have an Ariba Network tab with a number of APIs.
This you will only get in the US, as we speak, as the Ariba Network is hosted from the United
States.
OK Where the APIs are hosted also defines the
environment.
Here we can see that the production url is openapi.ariba.com
and the Oauth Server URL is api.ariba.com If we switch to Russia
It is ru.openapi.ariba.com and api-ru.ariba.com So, pay attention there
And for the other data centres this will be similar but slightly different.
OK - Now the first thing we need to do is get a token.
You will not be able to make any API call without a token.
This is documented here in the API developer guide.
You can use curl on the command line, typically when running scripts, and Postman if you want
a UI.
Now, anyone developing APIs will be familiar with Postman, so I am not going to explain
how this tool works, but for those not familiar yet, Postman is the equivalent of Visual Studio
for Windows, Xcode for iOS and macOS, Eclipse for Java, Android, C, ABAP, you name it.
It is the tool to use, when developing, testing, or documenting REST APIs.
go to getpostman.com for more information
We need to make a POST call to this URL v2 oauth token
authorisation is the oauth secret in base64 encoding - so it is always the same length.
The secret is provided when you create an application on the developer portal, we discussed
this in a previous video.
the value of oauth_server_url_prefix depends on the data center, as we just discussed.
Here in the US, that’s api.ariba.com
To demonstrate this, let’s switch to Postman.
I have started to create a collection for the Ariba APIs.
Here is the one for Analytics.
And I have posted these to GitHub.
So you can download and import the collection to your own Postman environment and try it
out for yourself.
Here we have GetOauthToken
It is a POST.
We are sending information and want some information back
The oauth-server_url_prefix, I have set as global environment variable in Postman.
with as value the US data center Oauth Server api.ariba.com
There are no query parameters.
In the header, as documented, we need to pass the oauth secret and also the content type.
In the body, we add grant_type = openapi_2lo
OpenAPI is an open-source project of the Linux Foundation.
Google, IBM, Microsoft are founding members, to name a few, and if you want to know more,
look it up on openapis (plural) .org
Click Send
and we get a response, 200 OK
with an access token and refresh token.
token type bearer and expiration 1,440 seconds or 24 minutes
Now, instead of copy-and-pasting these tokens each time in your GET request,
gets a bit tedious, with Postman, you can parse the response body
for the token and set this as an environment variable.
That is what we are doing here under the Tests tab.
And if we look at our environment variables we can see that the current value corresponds
to the response of the POST request.
same for refresh token
We have also set the realm and the API key as environment variable, plus the oauth client
secret, in base64 format.
If we return to the header, that’s the secret environment variable here between double curly
brackets.
Now, when we want to access any of the APIs,
Let’s open a metadata GET.
In the header, besides the API key, a required parameter will be the access token as authorization
parameter .
We can also refresh our token
Same POST URL, same header
But for the body we use grant_type = refresh token and with the refresh token as refresh
token, again using an environment variable.
OK, so much for Oauth tokens.
In the next video we will start with our exploration of the Analytics APIs.
Thank you for watching.