Chaining API calls

Complex filters & API calls

In previous example we used API call to third party service to check weather in the city. 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

_____________________________________________

CREATE API OPERATION FROM MOBSTED API

  1. Go to Keys tab

  2. Copy Primary and Secondary Key to your favorite note app

  3. Navigate to API Providers section in the left hand side menu and click Add API Provider

  4. Fill in:

    • Name: Mobsted 1

    • Base URL: https://demoapp-admin.mobsted.com

  5. Click Save API Provider and then click Create New API Provider Method

  6. Name the fields:

    • Api Provider Method Name: Weather to Column Method 1

    • Method: PUT

    • Endpoint URL: /api/v8/object/#Object:id#

    • Consumes Type: application/x-www-form-urlencoded

    • Produces Type: application/json

  7. Click Add Parameter at the bottom of the pop up and fill in the fields:

    • Name: applicationId

    • In: query

    • Type: Integer

    • Description: Application ID

    • Check the box Required

    • Click Save Parameter

  8. 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)

  9. Go to API KEYS tab and click Create New API Key

  10. On API Key - Create page fill in the fields:

    • Api Key Name: Mobsted Key

    • Method: Basic

    • For Key1 and Key2: copy-paste the keys you've copied on step 1-с

  11. Click Save and then Close.

__________________________________________

PASS PARAMETERS INTO 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.

____________________

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:

    • Name: varTemp

    • 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. Click Save screen.

________________

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

Last updated