Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 14 Next »

  • Description: REST API acts as a communication link between two platforms, enabling interaction through methods like GET (retrieve), POST (create), PUT (update), and DELETE (remove)


  • Path: (Rest API can be executed using Model and Workflow)

    • PWR Apps platform > Login > Business Node > Layout > Open a layout > Workflow > Rest API Action

    • PWR Apps platform > Login > Business Node > Layout > Open a layout > Model


  • Rest API Using Model

    • Prerequisite:

    • Create a Model:

      • Details:

        • Type: API

        • Connection: Choose the desired connection to fetch records from

        • Label: Auto-populates, mirroring the connection Label

        • Name: Auto-populates, mirroring the connection name.

        • Execute on load: If checked, records will be fetched automatically upon loading the component

        • Refer:

      • Request:

        • Method:

          • Choose from HTTP methods like Get, Post, Put, Delete, Head, or Patch based on the operation you want to perform

        • URL: Add the relevant URL that corresponds to the connection from which you wish to get, create, update, or delete records

        • Record Count: Set the record count to either Multirecord or Single, depending on whether you are dealing with multiple records or a single record in the data operation

        • Body > Schema Designer:

          • Generate Schema: Users can define fields using JSON format. For example

            {
                "Date": "05/12/2023",
                "Date and Time": "05/12/2023 11: 40 AM",
                "Double": 51.21,
                "Integer": 399,
                "Object": "",
                "Text": "Smith"
            }
          • Create New Fields: Users can create fields using create field Model

      • Response:

        • Response: User can create new response with the help of status code

        • Schema Designer:

          • Generate Schema: Users can define fields using JSON format. For example

            {
                "Date": "05/12/2023",
                "Date and Time": "05/12/2023 11: 40 AM",
                "Double": 51.21,
                "Integer": 399,
                "Object": "",
                "Text": "Smith",
                "Array": []
            }

          • Create New Fields: Users can create fields using create field Model

  • Crud using Rest API with Model in Workflow:

  • To Fetch Records:

    • Create a New layout

    • Table Setup:

      • Drag and drop a Table component onto layout Designer

      • Add Table action as New and Refresh

      • Add row action on Table as Edit and Delete

    • Assign Model to Table Component:

      • Assign a model to the Table with the following details:

        • Type: API

        • Connection: Choose a connection e.g. Sales Connect

        • Label gets Auto-populates e.g. Sales Connect

        • Name gets Auto-populates e.g. Sales Connect

    • Request:

      • Method: GET

      • URL: /services/data/v56.0/query?q=select id,name,site from account

      • Record Count: Multirecord

    • Response:

      • Define or create a schema to fetch the response. This schema will structure the data received from the API call

        {
            "data": {
                "records": {
                    "Name": " ",
                    "Id": " ",
                    "Site": " "
                }
            }
        }
    • In Component Attributes:

      • Basic:

        • Model: Select the model e.g. Sales Connect

        • Schema Source: Select "Response" as the source

        • Response code: Set the response code to 200

        • In Fields:

          • Select data > record

        • Click on the Table component, and the Model fields will be displayed on the left side

        • Drag drop the fields on the Table component

    • Create a new workflow (defining Label and Name)

      • Show Spinner Action:

        • Drag and drop the "Show Spinner Action"

        • Define layout item (e.g., Table), variant, and size

      • Rest API Action:

        • Drag and drop the "Rest API Action"

        • Set the Source API Type to Model

        • Choose the Model (e.g., Sales Connect) assigned to the Table

      • Hide Spinner Action:

        • Drag and drop the "Hide Spinner Action"

        • Define the layout item

      • Connect Actions:

        • Connect the actions in the workflow

      • Add Condition on Connector Mapping:

        • After the Rest API Action, set a condition on connector mapping

        • Condition: Model: Sales Connect, Set Output > Response: data

      • Save the workflow

    • Call the workflow on component events

      • Refresh : tableAction

        • Select Action as Workflow

        • Select Config and define Select Workflow: (Select the workflow create for Get e.g. Get and Save

      • Save & Run the Layout

      • Preview:

        • On preview, click on the Refresh Button.

        • The Get workflow will be executed, fetching the records

  • To Create Records: POST

    • Create a New Layout

    • Form Setup:

      • Drag and drop a Form component onto layout Designer

      • Add Form Action as Cancel and Save

    • Assign Model to Form Component:

      • Assign a model to the Form with the following details:

        • Type: API

        • Connection: Choose a connection e.g. Sales Connect

        • Label gets Auto-populates e.g. Sales Connect

        • Name gets Auto-populates e.g. Sales Connect

    • Request:

      • Method: Post

      • URL: /services/data/v56.0/sobjects/Account

      • Record Count: Single

      • Body > Schema Designer

        • Define or create a schema to fetch the response. This schema will structure the data received from the API call

          {
            "Name": " ",
            "Site": " "   
          }
    • Response: No need to define response for POST

    • In Component Attributes:

  • To Update Records:

    • Method: PUT or PATCH (depending on your API)

    • URL: Set the endpoint for updating records.

    • Body: Specify the data to be updated using the Model and Schema.

  • To Delete Records:

    • Method: DELETE

    • URL: Input the endpoint for deleting records.


  • Rest API Using Request in Workflow

    • Config:

      • Source API Type: Rest API action can be executed by two methods Model and Request.

        • Model: It displayed the list of model created on layout designer in model node

        • Request: Request needs to configure in workflow to execute Rest API Action

          • Authentication Type

            • Public

            • Session

            • User Token

            • Connection > Connection

        • Request

        • Method

        • URL

        • Record Count

      • Body (Schema Designer Table) > Generate Schema Button > Create New Fields

      • Query Params

      • Header

    • Response

      • Record Count

      • Status Code

      • Body (Schema Designer Table) > Generate Schema Button > Create New Fields

  • Action Details

    • Label: Label of workflow action

    • Name:

    • Is Async

    • Description

  • No labels