Parameters

Function parameters pass data into the function from the jig that calls it. They make the function dynamic and reusable by allowing context-specific values, like user input, selected records, or settings, to be used during execution.

Parameters are defined by a name and a set of properties (such as type, location, and whether they are required). These names are then referenced throughout the function, for example, in REST paths, query strings, and input transforms.

Configuration options

Options
Description

location

The location determines where the parameter will be applied in the REST call as follows:

  • path - The parameter is available as a token in the URL's path.

  • query - A query string parameter will be added to the URL, using the function parameter's name as the key and its value as the query parameter value.

  • header - A header will be added to the request using the function parameter’s name as the key and its value as the header value.

  • body - When body is specified as the location, the function parameter is available in the function’s inputTransform. Any token matching the parameter’s name will be replaced with its value during execution.

  • credential - Specifies the type of authentication required for REST API calls. It ensures secure communication between the app and the external API by attaching the appropriate authentication tokens or headers, as configured in Jigx Management.

  • secret - Securely references the client secret. Instead of hardcoding credentials directly into the function, you reference secret values that are stored securely in the solution's credentials in Jigx Management.

type

Type is specific to the REST call being made. Most types are defined as strings when they are used in path, query, or body locations. The available types are string, number, array, and object.

When types are declared in authentication header parameters, they are specific to the authentication type being configured.

required

The required value can be either true or false, indicating whether the parameter must be provided when the function is used in a jig’s datasource. Parameters used in URL paths must be set to required: true; otherwise, the function will generate an error. Set this property to true if the REST call requires the parameter, or false if the parameter is optional.

value

Provide a value for the parameter based on its defined location (e.g., query, header, path, or body) and type (e.g., string, number, boolean).

Example and code snippets

provider: DATA_PROVIDER_REST
# Updates data in the REST Service 
# PATCH modifies only the specified fields or properties of the resource.
method: PATCH 
# Use your REST service URL
url: https://[your_rest_service]/api/customers  
format: text
# Use local execution between the device and the REST service.
useLocalCall: true 
# Define parameters with header and body location.
parameters:
  accessToken:
    location: header
    required: true
    type: string
    # Use manage.jigx.com to define credentials for your solution
    value: service.oauth 
  id:
    type: int
    location: body
    required: true
  firstName:
    type: string
    location: body
    required: true
  lastName:
    type: string
    location: body
    required: true
  companyName:
    type: string
    location: body
    required: true
  address:
    type: string
    location: body
    required: false
  city:
    type: string
    location: body
    required: false
  state:
    type: string
    location: body
    required: false
  zip:
    type: string
    location: body
    required: false
  phone:
    type: string
    location: body
    required: false
 

Last updated

Was this helpful?