cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multi Tenant / TenantProvider

0 Kudos
744

Hello experts,

we have a CAP Java Multitenant Project and we need to get information about all subscribed tenants during runtime.

I tried following snippet corresponding to the capire docs (https://cap.cloud.sap/docs/java/multitenancy#accessing-arbitrary-tenants) to iterate through all tenants. We tested it both locally and on BTP/CF and although we do have active subscriptions, readTenants() always returns a List with exactly one item which is null.

Can you provide assistance?

TenantProviderService tenantProvider = runtime.getServiceCatalog().getService(TenantProviderService.class, TenantProviderService.DEFAULT_NAME);
List<String> tenants = tenantProvider.readTenants();
tenants.forEach(tenant -> {
	runtime.requestContext().privilegedUser().modifyUser(user -> user.setTenant(tenant)).run(context -> {
		..... your code
	});
});
View Entire Topic
jreimann
Participant
0 Kudos

Hi Jan, we faced the same issue.

You have to bind a instance of SaaS Provisioning Service to your application. In your application you can then call the endpoint <URL>/saas-manager/v1/application/subscriptions to get all tenants subscribed to your application.

There is also a SDK which can be used.

Regards
Johannes