Runtime Context¶
All event handlers receive the context
argument which is an instance of com.backendless.servercode.RunnerContext
. The argument provides access to additional contextual information for the event:
Argument | Description |
---|---|
context.getAppId() |
returns Application ID. |
context.getUserId() |
returns objectId of a user logged in in the client application which made the API call. If there is no logged in user, this value is null . |
context.getUserToken() |
returns the value of the user-token header representing session of the currently logged in user in the client application which made the API call. If there is no logged in user, this value is null . |
context.getUserRoles() |
returns an array of security roles of the user whose identity was used in the original API call. If there is no logged in user, the array will contain the NotAuthenticatedUser role and a role corresponding to the API key (for example RestUser if the request is made with the REST API Key). |
context.getHttpHeaders() |
returns java.util.Map<String, String> which is a collection of the HTTP header names and the corresponding values from the original request. |
context.getEventContext() |
returns the name of the "asset" for which the event has been triggered. This is useful for "generic" (catch all) event handlers which process events for multiple tables/files/messaging channels, etc. For instance, for the data event handlers, the method returns the name of the table targeted in the API call. For more information, see the Event Handler Asset section of the documentation. |