Invocation Context¶
The Backendless container which hosts and runs the services code provides a special object for every method invocation. The object is available via this.request
and provides access to the following data:
- Application ID - id of the application in which context the method is invoked.
this.request.context.appId
User ID - objectId
of the currently logged in user whose identity is used to invoke the method. A value for this parameter is not present if there is no logged in user (or if the user-token
header is not passed for the REST invocations).
this.request.context.userId
User token - value of the user-token
header sent by the client application when invoking the service.
this.request.context.userToken
User roles - an array of the role names of the logged-in user (if any) who made the API call.
this.request.context.userRoles
Device type - the type of the device which initiated the method invocation.
this.request.context.deviceType
HTTP headers - HTTP headers sent by the client application when invoking the service.
this.request.headers.<headername>
<service version>
:
https://api.backendless.com/<App ID>/<REST API key>/services/<service name>/<service version>/<path from @route>
the value is available by accessing:
this.request.path
this.request.pathParams.<parameter name>
for example, for the following parameterized REST route:
@route POST /contacts/{firstname}/{lastname}
and the following request path:
/contacts/Joe/Developer
the service code will receive the following this.request.pathParams
object:
"pathParams": {
"firstname": "Joe",
"lastname": "Developer"
}
this.request.queryParams.<param name>