Skip to content

REST Service Invocation

Backendless Console provides a visual interface for invoking service operations via the generated REST interface. To invoke a service operation, click its name. Console renders operation arguments based on the argument type information from the service code. Services implemented in JavaScript must use the JSDoc style annotations for describing method arguments to facilitate proper rendering of the method parameters form.

Important

Backendless Console uses the generated REST API when invoking service methods. As a result, you can also see the details of an invocation using the Network tab in the browser's developer tools.

HTTP GET operations

Parameters for the HTTP GET operations must be sent as URL's query params. Consider the following example:

/**
   * @param {String} itemName
   */
  getItem(itemName) {
   ...
  }

The method does not have an explicit @route annotation, however, since the method name starts with "get", Backendless will generate an HTTP GET route for the operation. Notice the @param {String} itemName annotation in the comment for the method. It instructs Backendless that the expected data type for the method argument is String and the argument name is itemName. When the method is selected in console, the parameter is rendered as shown below:

get-item-operation

Notice that you can specify additional parameters on the PARAMETERS tab. This is allowed because it is an HTTP GET operation and all parameters are sent to the server in the URL's query string - thus any parameters not explicitly defined by the method can also be sent to the service. Any "dynamic" parameters can be obtained in the code with :

this.request.queryParams.<param name>

HTTP POST|PUT|DELETE operations

Parameters for POST`PUT\DELETE` operations must be sent in the payload/body of an HTTP request. Console renders the parameters based on the description in the JSDoc comments. Consider the following example:

/**
   * @param {string} message
   * @param {boolean} important
   */ 
  addNote( message, important ) {
   ... 
  }

Just like with the GET example above, the method does not have an explicit @route annotation. Backendless creates a REST route based on the method name. Method name starts with "add" and per the REST Routes rules, Backendless will generate an HTTP POST route for the operation. For methods with more than one argument, Backendless combines them into a JSON object on the request side:

invoke-post-method-v4

Clicking the body schema area copies its contents into the body field where it can be edited. To invoke the method click the INVOKE button which sends a service invocation request to Backendless.