Skip to content

Invoking Service Method

REST Client

  1. To invoke the service method from Backendless Console, click the API SERVICES section and select the getServerTime method. Click the INVOKE button. Console makes a REST request to the service and displays the result:
    codeless-method-invocation.zoom50

    The method in this guide does not have any arguments, however, for other methods you will create, you can enter argument values on the PARAMETERS tab.
  2. For any invocation made in console a cURL command is generated so you can invoke the operation from a command line. Click the CODE tab and copy its contents. Paste it into a terminal/command prompt window and run the command:
    running-curl-codeless.zoom50

Generated SDKs (Android, iOS, JS)

  1. Backendless generates a client SDK for each API service. To download the SDK, click the download icon as shown in the image below:
    download-sdk-for-codeless
  2. Click the JavaScript option from the drop-down menu. You will download a zip file with the generated client-side code. Unzip the file into a directory. This directory will be referred to as <project-root> throughout this guide.

Important

This guide reviews service invocation from a JS client, however, similar instructions are applicable for other client types/languages.

  1. Open <project-root>/TimeService.html in a text editor and add the following <script> block. Make sure the code is added after the line which imports TimeService.js:
    <script>
        TimeService.getServerTime().
                then( function( serverTime ) {
            console.log( "Server time is " + serverTime );
        })
    </script>
    

Important

Notice the TimeService class (which is generated by Backendless) has the blocking and non-blocking implementation of the getServerTime method. Invoking your codeless method from a client is as simple as a local object invocation.

  1. Save the file and run it in a browser. When the page loads, open the Console tab for the browser developer tools, you will see the following output, which is a response from your codeless service:
    browser-invoking-codeless-service

This concludes the quick start guide. Happy Codeless Coding!