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 previous videos of this series, we explained how to get started with the developer portal
and how to work with the Oauth tokens in Postman.
For this video, I assume you are familiar with these topics, so we can dive straight
into our APIs.
In this video and the next, 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 I am connected here to the Developer Portal,
United States Data Center developer.ariba.com/api
connecting with SSO Here, under the Discover menu, we find all
the available APIs and for this video, we will take the first
tab ANALYTICS and here we find four APIs.
Analytical Reporting - View Management Job Submission
Job Result Synchronous, this also for jobs.
We are on v1, version 1, here for these APIs and you may have noticed hat the Rate limit,
the number of request, per second, per minute, per day,
actually slightly changes, depending on the API
Here we have the URLs for runtime environment and for the OAuth server, to get our tokens.
And here we have the actual APIs.
Three GETs and two POSTs.
There is on GET on /metadata All the others are on /viewTemplates
You can download the API specification.
That is a Swagger file in JSON.
Before openAPI was open-sourced, it was called Swagger
and the company currently owning it is called Smartbear.
You can go to swagger.io and log in Here we have the Swagger Inspector
Works the same as Postman, with collections and so on
Here we can upload our swagger file and this will display the URL
the parameters, authentication, body, etc.
We will be using Postman for our APIs, but just in case you wondered what you could do
with a Swagger file You can also run in to locally
Here I am using a Docker image, but you could do a local install as well.
And when we now open the Swagger file, you can see that it looks exactly the same
as on the developer portal.
Which is the whole point, with Swagger you can document your APIs in a generic common
format machine readable and language agnostic
This way not only the developer can understand the API specification but you can also create
tests, generate implementation code, say, for Java, for example - you can find examples
of this on the SAP API Hub - but the API definition can also be used to monitor your APIs.
Very imported if you have any SLA attached to the service you provide.
OK Back to our Developer Center
Let’s take a look a /metadata Four parameters are required
the realm - this will be required for most, if not all Ariba APIs
the apiKey - same story the product parameter - and here we can read
that for our Analytical Reporting API the value of this field should always be “analytics”
while getting metadata information of analysis fact/dimension document types
The reason is, if we go to procurement
as you can see we also have a View Management API, this time
for operational reporting and the value should be “buyer” or “sourcing”
and if we go to the strategic sourcing tab again, we have operational reporting APIs
get metadata and this time product = ACM Ariba Contract
Management Back to Analytics
View Management GET metadata
There is one parameter left: documentType This one is optional
If you do not provide it, you get all document types; that will be a long list
and otherwise it is filtered on the one specified.
Here we have a sample response for Code 200 Document Type InvoiceLineItemFact with filter
fields Invoice number, purchase order ID, etc.
and also examples for how 403 forbidden and 404 unauthorised look like
so you can handle this gracefully in your application
You can try it out Put in any realm
product = analytics I will paste in a sample document type
and you will need to enter your API key we discussed this in video number 1
Here is the response We get the CURL code, this can be used for
automation and the response body.
which, as you can see, contains a lot of rows. — and here we have our sample code again.
OK So, how does this look on Postman?
Here we our GET metadata URL with the product and realm query parameters
the apiKey is specified in the header which is also the place where we provide our
token for authorization Maybe as a reminder,
we talked about this in the video about Oauth and tokens
I am using environment variables here in Postman for this.
Makes it a bit easier, more flexible.
We have the runtime URL, the API key, realm and token.
This one will have been expired.
So, let’s make a POST request for a new token first
OK and now we can run GET metadata
Status 200 OK Took almost 2 seconds and we got a fair amount
of data back This can be restricted if we add a SELECT
to our query with value documentType This just returns the name of the different
documents but not all the filters
and if we then have selected the document we want
we can provide this as value of the documentType parameter in the get metadata request
and now we are just querying the values for a single document
which requires less time and less data.
OK, so much for GET metadata
In the next video we will continue our exploration of the Analytics API.
Thank you for watching