Chaining API calls

In the previous example we used API call to third party service to get the weather of the city entered. Now we extend it by passing the data to the next API call. We will use next API call to save the weather data into internal platform storage - column LastCityTemperature in Objects.

Steps to take:

Make sure you have accomplished the steps described in Use any external & internal API article before implementing the steps below.

  1. CREATE API OPERATION FROM MOBSTED API
  2. PASS THE PARAMETERS INTO THE API OPERATION
  3. CREATE USER VIEW
  4. CHECK RESULT

_____________________________________________

  1. CREATE API OPERATION FROM MOBSTED API
    1. Navigate to MY PROFILE section in the top right corner
    2. Go to Keys tab
    3. Copy Primary and Secondary Key to your favorite note app
    4. Navigate to API Providers section in the left hand side menu and click Add API Provider
    5. Fill in:
      1. Name: Mobsted 1
      2. Base URL: https://demoapp-admin.mobsted.com
    6. Click Save API Provider and then click Create New API Provider Method
    7. Name the fields:
      1. Api Provider Method Name: Weather to Column Method 1
      2. Method: PUT
      3. Endpoint URL: /api/v8/object/#Object:id#
      4. Consumes Type: application/x-www-form-urlencoded
      5. Produces Type: application/json
    8. Click Add Parameter at the bottom of the pop up and fill in the fields:
      1. Name: applicationId
      2. In: query
      3. Type: Integer
      4. Description: Application ID
      5. check the box Required
      6. Click Save Parameter
    9. Click Add Parameter again and fill in the fields:
      1. Name: LastCityTemperature
      2. In: query
      3. Type: String
      4. Description: Last City Temperature
      5. check the box Required
      6. Click Save Parameter and then Save API Provider Method
      7. Click Close
        NOTE: the name of this parameter must match the name of your column that will store the temperature (LastCityTemperature)
    10. Go to API KEYS tab and click Create New API Key
    11. On API Key - Create page fill in the fields:
      1. Api Key Name: Mobsted Key
      2. Method: Basic
      3. For Key1 and Key2: copy-paste the keys you've copied on step 1
    12. Click Save and then Close.

__________________________________________________

  1. PASS THE PARAMETERS INTO THE API OPERATION
    1. Click Operations in the left hand side menu
    2. Click Add Operation
    3. Open Mobsted 1 drop down on the left, select Weather to Column Method 1 that we created on the previous step
    4. Fill in the field: Operation Name: Weather to Column Operation 1
    5. In the EXECUTION section fill in the parameters:
      1. API Key: Mobsted Key
      2. applicationId: 1
      3. LastCityTemperature: #Variable:varTemp#
    6. Click Save Operation.

_______________________

  1. CREATE USER VIEW
    1. Navigate to Constructor to the screen created with previous steps
    2. Select button Check #Backendname:city# and click Actions, and then Add new Action
    3. From the drop down select Set Variable, click Add item and fill in:
      1. Name: varTemp
      2. Value: #Backendname:city# : #Operation:weather Operation:Response:Result[0]:current.temp_c#
    4. Click Save
    1. Click Add action, select Execute Operations from the first drop down and select Weather to Column Operation 1
    2. Click Save
    3. Drag and Drop Text element under the element where we display the current temperature, fill in it's properties:
      1. Backendname: LastCity
      2. Text: Last Check: #Object:LastCityTemperature#
    4. Click Add Conditions in Visibility block in the Properties
    5. Fill in the first field in Hide conditions with: #Object:LastCityTemperature#
    6. Click Save screen.

___________________

  1. CHECK RESULT
    Click Preview button to launch the app from the current screen to check it works.

You can check the set up described on screen - 14 Chaining Internal API in Demo App in your profile.

MENTIONED ARTICLES


Was it useful?