Welcome to this series of hands on tutorials from the SAP HANA Academy
I'm Philip Mugglestone
in this series. We're covering the SAP Business Technology Platform
in this video tutorial we're going to look at how you can use the SAP BTP
API It's another way that you can
actually perform operations within your SAP BTP environment.
So for example
create services, associate services or create sub accounts,
Delete sub accounts set, entitlements etcetera.
It is a little bit more complex to set up than
using the cockpit itself or using the command line interface.
Now the first thing is probably to go to look at the help guide. So help.sap.com/docs/BTP
we've seen that previously and then
you can go into the operate and the administration and manage
and operate your accounts and then the account administration and then
you'll find a section on account administration Using API S.
Now, just be aware this is only available if you're using feature set B.
We've talked about that before.
Again for your user just confirm that
for this global account cloud management tools.
Our feature set B that should generally be the case these days.
Now,
unlike the command line interface where you have all sorts of different things.
Entitlements and sub accounts and the environments all
managed the same to the same command line interface
with the API yes, there are different specific API s for different topics.
So you typically need to work with multiple API s
so if we select this link here on account administration,
you can see that we've got some information on exactly how you go ahead about using
that in particular you're going to need to
create an instance of the SAP Cloud Management service for SAP BTP.
So it's known as the C. I. S. With the central service plan,
which is then going to give you the ability
to do things such as reading information about global accounts
etcetera.
So there are different service instances you'll need to work with to do this.
Now if you want to find more information about what the API can actually do,
then the best place to go is to api.sap.com
And there we've got the SAP BTP section.
So for SAP API Business Hub
and then if we look at API s and we look at rest API s
then for example we've got the accounts service and this is one
of the example of the one of the core services available.
You can actually see the API reference for it.
So you can see these are the endpoints you can call.
If you want to actually create a sub account,
then you would use a post basically on the sub accounts,
you've got the same kind of operations that you would be doing when you're working
with the cockpit or with the command line interface in order to actually use it.
You're gonna need to create a service instance in
one of the sub accounts that you've got.
So maybe you want to create a specific sub account that's just
for this purpose or you take one that you've already got.
So maybe I'll just go with this one we created
in the previous video tutorial so I need to make sure
I've got the entitlement set up for it and it's the
SAP Cloud Management service for SAP BTP so it's not in the list already.
So I'm going to configure entitlements,
add service plan
and then look for the
SAP Cloud Management service for SAP BTP
and I'm going to use the central plan
and then hit
add
and save
and then I can go ahead and create a service instance.
So what we need to do is to create and then we'll choose the SAP Cloud Management service for SAP BTP,
central plan and we don't need to use a runtime environment,
we can just set it to other
can give a name, we call it maybe C I S
hit next,
we can stick with the default values here. Hit next
and hit create
now.
Once we've done that we'll need to create a service binding that will select here
create service binding,
give it whatever name we want
to create
and now if we have a look at it, we can download it.
Of course we can see we've got the different endpoints that are available
and we can also see that we've got the client ID client secret
and the URL we can use when we want to get access token.
Should be everything we need to now actually go ahead
and use this
now if you want to see details in the reference guide of how you
can actually get access to the token you can use this getting an access token
give you
example on exactly how you would go about that process.
It's what we've just done creating a service key etcetera.
So there are different ways that we might want to try this out.
Good ways to use Postman So let's go ahead and actually try with Postman
so we can set up a new request.
So the first thing we need is the URL basically to get the end
point so we can find that from the service binding that we created.
So we go and look at the end points we can see here is one for the accounts service
so let's copy that
and then of course we'll need the end point we're going to use on the end of it
and that we can easily get from here
for example accounts v1 directories so in this case
we might want to get the global account
information so we can say accounts v1 global account
but of course if we just tend to send
it's gonna say not found what we need to do is make sure that we have
authorized ourselves so for authorization what we're gonna do is set to use o off two
and we're gonna make it use grant type of password
credentials so we need to have an access token.
URL again we can get that from the service key. So it's the the UAA section it's the U.
R. L.
But we need to put
/oauth/token
on the end
we'll need the client I. D. So the client I. D. Is here,
we'll need the client secret
and we'll also need a user name
because you do need to have actually an
authorized user within SAP BTP to actually call this API
So I'm going to use the user I've used here but
for you I would recommend that you create a technical user,
don't use your main interactive user for such programmatic access.
So then we should be able to go ahead and get a new access token
and then we can use the token
and we can hit send
and now you can see we've made a query
and we've got information back on our global account.
So basically that's how you can go ahead and use the SAP BTP API we've seen here
an example from Postman you just need to call the right URL with the right endpoint
and make sure that you've actually used password credentials with
all the right settings in there to create your access token
and then you can do your get create
and then you can do your get or your post
or your put whatever kind of operation you want to do
and of course as we've already seen you'll
find more information about how you do that
from the SAP API Business Hub has got the
key information on how the whole API is structured
and if you get and if you want more information
on how you actually just get started with it,
create the service instance.
Then again, that was available from the main help portal.
In the account administration section.
You can find more video tutorials on our Youtube channel
if you'd like to be informed as soon as new video tutorials are published,
then please subscribe.
Thanks for watching.