Using the DS Session / DS Services

To use the DSX REST API you need to establish a so-called 'tenant session'. This session is used to authenticate the user, or actually the agent that you are connecting as to your 3DX tenant.

To get the session, you will from the context object first obtain the DSX API reference. From this API, you can get, for example, the "3D Space Service". And once you have the service, you need to get a session object that is valid for that service.

See example below how this is done.

const dsAPI = context.dsxAPI();
const spaceService = dsAPI.getSpaceService();
// Now get the session valid for the 3DSpace service
const session = dsAPI.getTenantSession(spaceService);

You need these two objects to be able to conduct queries against the 3DSpace application within the 3DEXPERIENCE™ Platform.

The Agent that you are connecting with is configured outside the code on either the Event/REST mapping or Scheduled Task depending on how the job is being triggered.

Security Context

When performing the operations on the data in the 3DEXPERIENCE™ platform, you also need to consider what security context you are using when performing the operations. The used security context can also be configured outside the code in the same place as where the agent is configured, e.g on the Event/REST mapping or Scheduled Task.

However, you can also during the code execution change the security context. This is done like shown below:

session.setSecurityContext('VPLMProjectLeader.Company Name.My Collab Space');

If no security context is configured, the system will try to resolve a default security context based on the current user.

This is not giving predicable result in all cases so the recommendation is to configure this preferably on the Event Mapping, REST Mapping or the Scheduled task.

If necessary, compute and set this at runtime via the API.