[2019.11] SAP Ariba APIs – Analytical Reporting View Management viewTemplates

[2019.11]  SAP Ariba APIs – Analytical Reporting View Management viewTemplates

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 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 am going assume you are
familiar with these topics, so we can dive straight into our APIs. 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 Here, under the Discover menu, we find all
the available APIs and for this video, we will continue with
ANALYTICS, on the first tab. Analytical Reporting – View Management
In the previous video, we discussed the GET metadata API. For this video, we will address viewTemplates. There are two GETs and two POSTs. With the first POST we can create a view template
and with the second POST, a patch, we can do an update. Normally, you would use the PATCH verb for
this, so PATCH instead of POST but this works a bit differently and we look into that in
a minute. Let’s start with the GETs.
/viewTemplates will get us all views and /viewTemplates/viewTemplateName just the
metadata for a single view. viewTemplates requires two parameters: realm
and API key As the list for all views of a customer or
realm can be quite long, we can also provide a page token so we can paginate. Here we have the sample output for 200, successful
response this just returns the view template name and
any filter expression with creation date with the output for 403, 404 and 500 – these are
usually pretty much the same for GETs. To get a single view metadata, we add the
view template name to the path, and this returns the same metadata, this time for the template
we requested. No surprises here. Let’s proceed with the POST. It is the same URL. But now we need to provide a body with the
document type, a status, the selection attributes, filter expressions, and if all is well, we get a 200 back with
the message view template is created/updated successfully. There is a 400 message in case of invalid
select attributes, and the 403 and 404s are the same as before. Finally, we have patch; /patch is appended
to the URL, it is not a verb, it is still a POST. And with patch we can change the status for
the view template to either published or deactivated. If you want the template to have the draft
status, you should define this in the original POST when creating it. Quick reminder
If you want to know more, see the documentation. It is on Ariba Connect
support.ariba.com Here under Analysis API help
you can look it up For those more familiar with the SAP documentation,
there is good news. As we find the same information also on help.sap.com
Just search for ariba API and select the Ariba API portal page
and open the Analysis API from there Same information, maybe a litter better presentation,
but this might be a personal preference. OK
Let’s run this in Postman Here we have our Postman collection
Links to the GitHub code source repository below on the description of this video when
watched on YouTube. View templates
Let’s first get our oauth token We have covered this in a previous video. Same for working with environment variables
in Postman. Let’s start with get all views. URL is /viewTemplates
Parameters are realm and an optional page token
In the header we need to provide our API key, and our oauth token. Click send
This will take a bit of time actually. 4.4 seconds
a lot of metadata and if we scroll all the way to the bottom,
here we have a page token. and this we can pass in the URL to get the
next page and the next,
and so on OK
let’s copy a view template name Next, we are going to use the URL for a single
view /viewTemplates with the name of the view template
name appended to the path. Let’s paste that in here. Send
and now we have the metadata for just this one view template
with the document type, select attributes, and so on. OK
Let’s proceed with the POST call creating a view template
URL remains the same but now we do a POST Same parameters
realm and the view template name in the header our API key
and in the body, the document definition document type
status select attributes,
and filter expressions Now, when the view already exists we get a
400 bad request message view already exists
So, lets change the name here and now we have a new view template
I have set the status to draft so in the Ariba UI we could test this out.
and when all is well, we can do an update same URL with /patch appended
The verb is still POST, do not confuse this There is a PATCH verb as well but we are not
using that here. realm, template name
api key and in the body, just an update for the status:
published or deactivated, as documented Send
200 OK and the status has been updated. OK, that’s it for view templates. In the next video we will continue our exploration
of the Analytics API and take a look at the jobs. Thank you for watching

Leave a Reply

Your email address will not be published. Required fields are marked *