Quick Start Guide for REST API

This guide will help you get up and running with Backendless quickly so you can start using the Backendless REST API in your applications.  At the end of the guide you will have the basic knowledge of using the user registration and data persistence APIs. This guide uses the curl  command line utility to generate REST requests sent to the Backendless servers.

  1. Login to your Backendless account or register to create a new one.
  2. Navigate to Manage > App Settings:
  3. Locate Application ID and REST Secret Key of your backend. These values will be used later in the guide:

  4. The first REST request you will send is to register a user for your app. Open a command prompt/terminal window and make sure you can run the curl  command. All Backendless REST request must contain at least two special HTTP headers:

    When you enter the commands below, you can copy these values from the App Settings screen of Backendless console described in step 3.
  5. The structure of a command to register a user is:

    Enter the command in your terminal window and press Enter.
  6. If everything worked fine, your response would look like the on in the screenshot below (the HTTP response code and response body are highlighted). If the HTTP code is 200 – then everything worked fine and the user is registered. The server response body is a JSON object representing the created user. !Note: to avoid showing verbose requests and responses we will not use the  “-v” flag in the subsequent curl examples in this guide.
  7. You can verify that the user has been created by opening the Data screen of Backendless console. The user will appear in the Users table (which is selected by default).
  8.  Now that the user can been created, you can login that user with the command below:
  9. Take a look at the response of the login operation. This is also a JSON object representing the logged-in user. The response body contains an important property called user-token  ( it is marked with a white rectangle in the screenshot below ). Copy the value of that property:
  10. The next step is to create a data object in the Backendless data storage. The object will be an arbitrary object called Comment . Notice that the request contains an extra HTTP header called user-token . It indicates that the request is made by the logged in user (the same user who was logged-in in the previous step). The user automatically becomes the owner of the created object. Run the following command:

  11. The response sent by the server contains a JSON representation of the created Comment object. It has a system assigned field   ownerId which contains the objectId  of the user who is the owner of the object (if you do not understand what this means now, it is OK. This may become important later in your app).
  12. Now you can refresh the Data screen of Backendless console and verify that the Comment  table has been created and it contains an object created by user “”.