Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Sriprasadsbhat
Active Contributor

Introduction:


In most of the customer use cases there is always request for automation and handling different API Lifecycle Management activities using exposed system APIs.In below blog will try to explore how to manage different artifacts of API Portal and API Business Hub Enterprise using APIs.

Setting up API access:


Subscribe to SAP Integration Suite Free tier plan by following blog post.

Once successfully subsrcribed to SAP Integration Suite,follow below deatiled steps to expore different capabilities of SAP API Management.

API Portal :


Once SAP Integration Suite with SAP API Management is enabled click Instances and Subscription to create instance


 

Refer SAP Help documentation for understanding different roles related to API Portal which includes below use cases

Configuring additional virtual hosts:

Using Self service admin role to configure virtual host to be used in SAP API Management
{
"role": "APIManagement.SelfService.Administrator"
}

Handling SAP API Management artifacts using APIs:

Using Administrative role we could perform CRUD operations on different APIs of SAP API Management.
{
"role": "APIPortal.Administrator"
}

 


 

Once required parameters are filled click on Create to complete instance creation.


Select created instance and click on Create Service Key to use it further to retrieve/update/delete API Portal artifacts.


Now you have ClientId,ClientSecret and tokenUrl to be used further to retireve API Portal artifacts through API.


 

API Business Hub Enterprise Portal :


Once SAP Integration Suite with SAP API Management is enabled click Instances and Subscription to create instance


 

Refer SAP Help documentation for understanding different roles related to API BHE

Application Developer role:

Using service key generated by specifying developer Id CRUD operation on applications, API packages, and API proxies and products could be done.

To successfully create an application via the API business hub enterprise, you must provide a valid developerId. This means that you must have already registered as an application developer to the API business hub enterprise service or you must have been onboarded by your adminstrator.This helps to differentiate multiple developers performing different operations on APIs.

Administrator Role:

This role helps to access the API business hub enterprise APIs (applications and attributes, API packages, API proxies and products, app developer and metering), and perform operations like create, update, and delete on various API business hub enterprise entities.


Once required parameters are filled click on Create to complete instance creation.


Select created instance and click on Create Service Key to use it further to retrieve/update/delete API Management,Business Hub Enterorise artifacts.



Exploring SAP API Management API portal APIs:


APIs related to API Portal could be accessed using below url.
https://<tenant_url>:443/apiportal/api/1.0/Management.svc

Make a metadata call to explore list of Enttity Sets you could use for API Portal.Use clientId,clientSecret and tokenURL from service key and make a call to below url.
https://<YourtenantspecificURL>:443/apiportal/api/1.0/Management.svc/$metadata

Below is list of EntitySet associated with APIPortal.






















































































API Portal
RouteRules APIProviders
Applications ApplicationAdditionalPropertys
ContentPackageMappers APIProxies
ApiportalCloneMappings TemplateFileResources
KeyMapEntryValues RatePlans
APITargetEndPoints APIResources
TemplatePolicys APIProxyEndPoints
ACLProductLinkages Resources
DestinationAndUrlMappings KeyMapEntries
APIProviderAdditionalPropertys EndPointProperties
FlowRules Policies
Documentations Certificates
APIProducts FileResources
GenericKeyMapEntryValues CacheResources
Bills PolicyTemplateContainers
VirtualHosts DefaultFaultRules
CertificateStores APIProductAdditionalProperties
Steps FaultRules
GenericKeyMapEntries ConditionalFlowRules
Developers

Lets consider one of the EntitySet : APIProvider and see how to create,read and delete it using API.

CREATE:

Url:
https://<YourTenantSpecificURL>:443/apiportal/api/1.0/Management.svc/APIProviders

Authentication: OAuth 2.0 ( use the details from Service Key generated for API Portal

Operation: POST

Sample Payload:
{
"description": "ES5_1",
"destType": "INTERNET",
"host": "sapes5.sapdevcenter.com",
"name": "ES5_1",
"trustAll": true,
"title": "ES5",
"authType": "BASIC",
"port": 443,
"pathPrefix": "/sap/opu/odata",
"useSSL": true,
"isOnPremise": false,
"cloudConnectorLocation": "null",
"url": "/iwfnd/catalogservice/ServiceCollection",
"userName": "User",
"password": "PASSWORD"
}

DELETE:

Url:
https://<YOUR_API_PORTAL_URL>:443/apiportal/api/1.0/Management.svc/APIProviders('ES5_1')

Authentication: OAuth 2.0 ( use the details from Service Key generated for API Portal)

Operation: DELETE

Sample Payload:Not Required

Exploring API Business Hub Enterprise APIs:


APIs related to API Business Hub Enterprise could be accessed using below url.
https://<YourAPIBHEUrl>:443//odata/1.0/data.svc

Make a metadata call to explore list of Enttity Sets you could use for API BHE.Use clientId,clientSecret and tokenURL from service key and make a call to below url.
https://<YourAPIBHEUrl>:443//odata/1.0/data.svc/$metadata

Below is list of EntitySet associated with API BHE.

 










































API BHE
APIMgmt.Applications
APIMgmt.APIProducts
APIMgmt.APIResources
APIMgmt.ProxyEndPoints
APIMgmt.APIProxies
APIMgmt.APIResourceDocumentations
APIMgmt.RatePlans
APIMgmt.Subscriptions
APIMgmt.Attributes
CatalogResources
Comments
Ratings

Lets consider one of the EntitySet : APIMgmt.Applications and see how to create,read and delete it using API.

CREATE:

Url:
https://<Your Business Hub Enterprise URL>:443/odata/1.0/data.svc/APIMgmt.Applications

Authentication: OAuth 2.0 ( use the details from Service Key generated for API BHE

Operation: POST

Sample Payload:
{

"id": "00000000000000000000000000000000",

"version": "1",

"title": "ES5TestSri",

"description": null,

"callbackurl": null,

"developer_id": "<DEVELOPER_ID>",

"ToSubscriptions": [{

"ToAPIProduct": [{

"__metadata": {

"uri": "APIMgmt.APIProducts('SAPES5Application')"

}

}

],
"ToRatePlan": [{
"__metadata": {
"uri": "APIMgmt.RatePlans('c07q973e-b188-40ea-af2e-71365bc95ef2')"
}
}
],
"id": "00000000000000000000000000000000"

}

]

}

Note: developer_id is optional and it is required if on behalf of other developer id we are performing CRUD operations on the API.

DELETE:

Url:
https://<YOUR_API_BHE_PORTAL_URL>:443/odata/1.0/data.svc/APIMgmt.Applications('4C71D3DF-3308-4FD7-B625-125029194873')

Authentication: OAuth 2.0 ( use the details from Service Key generated for API BHE )

Operation: DELETE

Sample Payload:Not Required

 

Conclusion


Hope this helps consultants and customer to automate SAP API Management Life Cycle Management Activities easily.

 
3 Comments