REST API Configuration

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

  • Ways to Configure REST API in noKodr: Rest API can be executed using Model and Workflows

    • noKodr platform > Login > Layout > Open a layout > Workflow > Rest API Action

    • noKodr platform > Login > Layout > Open a layout > Model

  • Prerequisite: Create a Named Credentials, Auth Provider and establish a connection. Refer to Named Credentials and Auth Provider.

  • Steps to Create Named Credentials:

    1. In Salesforce Setup, navigate to ”Named Credentials” under ”Security.”

    2. Click ”New Named Credential.”

    3. Enter the details, including the name, URL, and identity type.

    4. Configure the authentication settings based on the requirements (e.g., password, OAuth, or JWT).

    5. Save the Named Credential.

  • Steps to Create Auth Provider:

    1. In Salesforce Setup, go to ”Auth. Providers” under ”Security Controls.”

    2. Click ”New” to create a new Auth. Provider.

    3. Select the type of provider (e.g., OpenID Connect, SAML, etc.).

    4. Fill in the necessary details such as the name, callback URL, and other provider-specific settings.

    5. Configure the authentication settings and set the appropriate scopes or permissions.

    6. Save the Auth. Provider configuration.

      By following these steps, you can create named credentials and an auth provider in Salesforce to establish secure external connections and authenticate users for various integration and external services

  • Steps to create a connection with external source in noKodr:

    1. Create an Account to the respective web application you want to integrate with noKodr

    2. Get the ’Client ID’ and ’Client secret key’ of that web application.

    3. Create the auth Provider in salesforce.

    4. Create the Named Credential in Salesforce using Legacy

    5. Open noKodr and Create a Model using Connection as API

    6. Request for the operation you want to perform by clicking the ‘Request’ tab of the ‘Update Model’

    7. Click on the ‘Response’ tab of the ‘Update Model’ to generate schema as per the response you want to get.

    8. Click on Merge.

  • API Type Model: The API type model acts as a communication link between two platforms, enabling interaction through methods like GET (retrieve), POST (create), PUT (update), and DELETE (remove).

    How to configure API type model:

    • Prerequisite: Create a Connected App, Named Credentials, Auth Provider and establish a connection as mentioned above

      1. Create of Model with the following field values:

        • 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

          create model.png
          Create Model
      2. Click on the Request tab and choose the values respectively.

        • 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:

          Schema Designer.png
          Schema Designer

          There are two ways to provide the request body.

          • 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 the create field Model

      3. Click on the Response tab and choose the values respectively.

        • Response: The user can create a new response with the help of the 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 the create field Model

  • CRUD using Rest API with Model in Workflow:

    • To Fetch Records: Use Get Method >

      1. Create a new layout

        Table Setup:

        1. Drag and drop a Table component onto the layout Designer

        2. Add Table action as New and Refresh

        3. Add row action on Table as Edit and Delete

      2. Assign Model to Table Component

        Assign a model to the Table with the following details:

        1. Type: API

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

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

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

      3. Request

        Request with the following details:

        1. Method: GET

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

        3. Record Count: Multirecord

      4. 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”: ”

        1. In Component Attributes:

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

          2. Schema Source: Select ”Response” as the source

          3. Response Code: Set the response code to 200

        2. In Fields:

          1. Select data > record

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

          3. Drag-drop the fields on the Table component

          4. Create a new workflow (defining Label and Name)

        3. Show Spinner Action:

          1. Drag and drop the ”Show Spinner Action”

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

        4. Rest API Action:

          1. Drag and drop the ”Rest API Action”

          2. Set the Source API Type to Model

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

        5. Hide Spinner Action:

          1. Drag and drop the ”Hide Spinner Action”

          2. Define the layout item

        6. Connect Actions:

          1. Connect the actions in the workflow

      5. Call the workflow on component events

        1. Refresh: table Action

        2. Select Action as Workflow

        3. Select Config and define Workflow: (Select the workflow created for Get e.g. Get and Save)

        4. Save & Run the Layout

      6. Preview

        1. On preview, click on the Refresh Button.

        2. The Get workflow will be executed, fetching the records

    • To Create Records: To POST >

      1. Create a new layout

        Form Setup:

        1. Drag and drop a Form component onto layout Designer

        2. Add Form Action as Cancel and Save

      2. Assign Model to Form Component

        Assign a model to the Form with the following details:

        1. Type: API

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

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

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

      3. Request

        Request with the following details:

        1. Method: Post

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

        3. Record Count: Single

        4. 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”: ” ”

      4. Response

        Response with the following details

        1. No need to define response for POST

        2. In Component Attributes:

          Basic:

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

          2. Schema Source: Select ”Request” as the source

          3. Now Fields will be displayed at the left corner drag and drop the fields on the form

          4. Create a new workflow (defining Label and Name)

        3. Rest API Action

          1. Drag and drop the ”Rest API Action”

          2. Set the Source API Type to Model

          3. Choose the Model (e.g., Sales Connect) assigned to the Form

        4. Toaster Action:

          1. Drag and drop the ”Toaster Action.”

          2. Fill Type with ”Success” and Message with ”Record created successfully!”

          3. Save the Toaster Action

        5. Emit Action:

          1. Drag and drop the ”Emit Action”

          2. Add the event you have created

          3. Save the Emit Action

        6. Connect Actions:

          Connect the actions in the workflow

      5. Call the workflow on component events

        1. Click on the form and navigate to Events > Save : Action.

        2. Select Action as Workflow

        3. Select Config and define Workflow: (Select the workflow created for Post e.g. Post and Save)

        4. Save & Run the Layout

      6. Preview: On preview, check if the record is getting saved by clicking on the Save Button

        Note: To execute CRUD for the Rest API go to the layout where you have drag dropped the table. Follow these steps on the layout where you have drag-dropped the table

        1. Create a Pop and refresh workflow

        2. Drag and drop POP action and add a label and Save

        3. Drag and drop Workflow action and select the workflow created for the Refresh Button

        4. Connect the actions and Save the workflow

        5. Click on the table and navigate to Events > New : tableAction

        6. Select Action as Push Modal

        7. Select Config and define Push Modal model

        8. Layout: Choose the layout created for the POST method e.g Connection Post

        9. Event: Select the event created on the POST Method layout

        10. Workflow: Select the Pop and Refresh workflow and Save

        11. Save & Run the Layout

          Preview:

          1. On preview, click on the New Button.

          2. And Fill the data in the fields and save

          3. Check the same on the Connected app i.e. Salesforce Account >navigate to Accounts from app launcher > view the change

  • To Update Records: Patch>

    • Create a new layout

      Form Setup:

      1. Drag and drop a Form component onto the layout Designer

      2. Add Form Action as Cancel and Update

    • Create a variable:

      1. Add Label & Name

      2. Type: Object

    • Add Schema:

      1. Add Label and Name

      2. Field Type: Object

      3. Schema: Add Schema Id, Name, and Site

      4. Click Save

    • Assign Model to Form Component

      Assign a model to the Form with the following details:

      1. Type: API

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

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

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

    • Request

      Request with the following details

      1. Method: Patch

      2. URL:/services/data/v56.0/sobjects/Account/variable:object.Id (Note: Use merge text for Id)

      3. Record Count: Single

      4. 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”: ” ”

      5. Response: No need to define response for Patch

  • In Component Attributes:

    Basic

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

    • Schema Source: Select ”Request” as the source

    • Now Fields will be displayed at the left corner drag and drop the fields on the form

    • Create a new workflow (defining Label and Name)

    • Workflow 1: For e.g. name it as Put Data

  • Log Action:

    • Drag and drop the Log Action

    • In the Config section, add Log Source: Variable and choose the Variable: Select the variable you created

    • Add Action details and save the log action

    • Assignment Action:

      1. Drag and drop the Assignment Action

      2. Add conditions: Condition 1:

        1. Destination Type: Model

        2. Model: Select the model assigned to the Form

        3. Schema Source: Request

        4. Fields: Keep it blank, but ensure that fields are visible

        5. Operator: Set

        6. Source Type: Variable

        7. Variable: Select the variable you created at the start

      3. Condition 2:

        1. Destination Type: Model

        2. Model: Select the model assigned to the Form

        3. Schema Source: Request

        4. Fields: Id

        5. Operator: Set

        6. Source Type: Null

  • Connect Actions

    • Connect the actions in the workflow

    • Save the workflow

    • Assign Workflow 1 on the on-load event of the form Workflow 2. For e.g. name it as Patch Records

      1. Rest API Action:

        1. Drag and drop the ”Rest API Action”

        2. Set the Source API Type to Model

        3. Choose the Model (e.g., Sales Connect) assigned to the Form

      2. Toaster Action:

        1. Drag and drop the ”Toaster Action.”

        2. Fill Type with ”Success” and Message with ”Record updated successfully!”

        3. Save the Toaster Action

      3. Emit Action:

        1. Drag and drop the ”Emit Action”

        2. Add the event you have created

        3. Save the Emit Action

        4. Connect Actions: Connect the actions in the workflow

        5. Save the workflow

        6. Assign Workflow 2 on the Update button

        7. Save & Run the Layout

  • Preview: On preview, check if the record is getting saved by clicking on the Update Button.

    Note: To execute CRUD for the Rest API, go to the layout where you have drag-dropped the table. Follow these steps on the layout where you have drag-dropped the table:

    1. Create a Pop and refresh workflow

    2. Drag and drop POP action and add a label and Save

    3. Drag and drop the Workflow action and select the workflow created for Refresh Button

    4. Connect the actions and Save the workflow

    5. Click on the table and navigate to Events > Edit: tableAction

    6. Select Action as Push Modal

    7. Select Config and define the Push Modal model

    8. Layout: Choose the layout created for the Patch method e.g Patch Records

    9. Event: Select the event created on the Patch Method layout

    10. Workflow: Select the Pop and Refresh workflow

    11. Click Save

    12. On Events > Add mapping on Edits workflow

    13. Input Variable: Select the variable created on the patch layout

      Operator: Set

      Source Type: Output Variable

      Output Variable: Record

    14. Save & Run the Layout

      Preview:

      1. On preview, click on the Edit Button i.e. row action

      2. Fill the data in the fields and update

      3. Check the same on the Connected app i.e. Salesforce Account >navigate to Accounts from app launcher > view the change

  • To Delete Records: Delete

    1. Create a workflow in Rest API Presentation where you have dragged and dropped the table details

    2. Request:

      For URL merge text follow

      Note: No need to define Schema for delete

    3. Response: No need to define a response for Delete

    4. Workflow: Delete Records

      1. Prompt Action: Drag and drop the prompt action

      2. Rest API Action: Drag and drop the Rest API action

      3. Toaster Action: Drag and drop the Toaster action

      4. Connect Actions: Connect the actions in the workflow

      5. Save the workflow

      6. Assign the workflow on table action Delete

      7. Click on the table > Events > Delete :rowAction

         

      8. Add mapping on the workflow

      9. Save and Run the layout 10. Preview: On preview, check if the record is getting deleted by clicking on the delete button Button.

        Check the same on the Connected app eg. Salesforce Account >navigate to Accounts from the app launcher > view the change.