Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

The Enhanced JSON API plugin includes bundles built from the default JSON API, with added features such as support for system proxy settings, API tokens, customizable socket timeout retries, response formatting, additional PUT and PATCH request call. The default JSON API consists of:

Plugin Info

Plugins Available in the Bundle:

...

This plugin bundle is compatible with Joget DX 8 and onwards.

Expected Outcome

To be able to work with JSON API calls through form binder, form options binder, list binder and process tool.

Get Started

Steps

Where to get the plugin

...

Figure 5: Access token in cache

Enhanced JSON API Properties

Enhanced JSON API 

Note
iconfalse

This plugin's configuration is identical to the bundled JSON API, only with the additional configurable properties below, which the name of the fields are in green.

...

Figure 6: Enhanced JSON API (Authentication)

NameDescription
Retrieve and Use Access TokenIf checked, access token will be included in the request headers. Use "{accessToken}" to access the value in the request headers.
Token URL *URL to retrieve the token from.
Request Type

Select the call type:

  • GET
  • POST
Access Token JSON Field Name *

The field name of the request call to retrieve access token from.

Store Access Token in Cache

If checked, access token will be stored in cache. If token is not expired, it will retrieve from cache instead of performing another request call.

Access Token Cache Expiry Time (minutes) *

The duration set for the cache to expire before making another request becomes necessary.

Request

Figure 7: Enhanced JSON API (Request)

NameDescription
JSON URL *URL to be called.
Call Type

Select the call type:

  • GET
  • POST
  • PUT
  • PATCH
Request Headers

Add name(s) and value(s) to the request header.

Response

Image RemovedImage Added

Figure 8: Enhanced JSON API (Response)


Image Added

Figure 9: Enhanced JSON API - Store Response Status (Response)

NameDescription
Connection Timeout (seconds)Specifies the maximum time (in seconds) that the client will wait to establish a connection with the server. If the connection cannot be established within this time, an error will be thrown and logged.
Socket Timeout (seconds)Specifies the maximum time (in seconds) that the client will wait for a server response after the connection is established. If no response is received within this time, an error will be thrown and logged.
Debug ModeShow relevant debug entries in the server log for debugging purposes.
Response Type

Types of response format

  • JSON
  • File
  • No Response
Format Response

Header. If Response Type is JSON, this section will be visible.

Enable Response Formatting

When checked, you can start writing a BeanShell script to format/post-process the JSON response.

Script

The "Enable Response Formatting" property must be enabled in order to write the BeanShell script here.

Injected Variables:

  • data - This is a Map object of the JSON response from the JSON API call.

Expected Return Object:

It is expected to return a Map object that would later on be processed as configured to store to form and/or workflow variables.

Example:

Return the response only for the first item in a JSON array with the object name "apps".

Code Block
languagejava
return data.get("apps")[0];
Store to Form

Header. If Response Type is JSON, this section will be visible.

FormSelect the target form to store data.
Base JSON Object Name for Multirow DataName of the object that contains an array to be based on.
Field Mapping

Mapping with JSON data with Form fields.

NameDescription
Field NameForm field ID
JSON Object NameJSON property name
Store to Workflow Variable

Header. If Response Type is JSON, this section will be visible.

Workflow Variable Mapping
NameDescription
Workflow VariableWorkflow Variable Name.
JSON Object NameJSON property name.
Store Attachment

Header. If Response Type is File, this section will be visible.

Form

Recommended to use a child form with foreign key to main record as in a single JSON call, data may be returned successfully but fails in parsing to JSON format.

File Upload Field

Fill in to use as foreign key to main record. Leave it blank to save form record ID into column "ID". When it is blank and there are multiple logs, logs will be overwritten and only the last entry will be visible.

Store Response Status

Header.

Workflow Variable to Store Response Status

Workflow variable name to store response status value.

Form

Recommended to use a child form with foreign key to main record as in a single JSON call, data may be returned successfully but fails in parsing to JSON format.

Response Field ID

Fill in to use as foreign key to main record. Leave it blank to save form record ID into column "ID". When it is blank and there are multiple logs, logs will be overwritten and only the last entry will be visible.

Response Status Field *

Field to store response status.

Response Data Field

Field to store reponse data.

Base JSON Object Name for Multirow Data

Name of the object that contains an array to be based on.

Field Mapping

Name

Description
Field NameForm field ID
Value
JSON Object NameJSON property name.
Field Mapping for Additional Attributes

To record additional attributes manually to provide clear insights on requests for audit purposes.

For example, we set the table as: 

origin : appABC
source: processABC
tool: Invoke Call X

Name

Description
Field NameForm field ID
ValueAttribute value

Source Code and Plugin Download

  1. You can find the latest release at https://github.com/jogetoss/enhanced-json-api/releases Joget Marketplace.
  2. Upload the plugin to your Joget by navigating to Settings > Manage Plugins > Upload Plugin as admin.

...