Introduction

The JSON API in a process enables one to issue a JSON web service call, and to save the returned data into Joget's form data and/or into the process's workflow variable. Download the demo app to try it out on your Joget DX platform.


JSON Tool Properties

Configure JSON API for Mapping Tools to Plugins

Figure 1: Configure JSON API for Mapping Tools to Plugins


NameDescription
JSON URLURL to be called.
Call Type

Select the call type:

  • GET
  • POST

GET requests include all required data in the URL. GET is less secure compared to POST because the data sent is part of the URL. So it's saved in browser history and server logs in plaintext.

In contrast, HTTP POST requests supply additional data from the client (browser) to the server in the message body. POST is a little safer than GET because the parameters are not stored in browser history or in web server logs. From here.

Body Type

(Only Applicable to Call type = POST)

Select the POST method:

  • Request Parameters
    • Add name(s) and value(s) to the request header

      FieldDescription
      NameName (or Type ) of the Request Header 
      ValueLink or Value of the Request Header
  • POST Parameters as JSON Payload
    • When POST Method is set to "POST Parameters", these parameters will be sent as a UrlEncodedFormEntity.

      When POST Method is set to "POST Parameters as JSON Payload", these parameters will be sent as a StringEntity in a form of an escaped JSON string.


  • Custom JSON Payload
    • Write your own JSON to be the payload. It will be sent as a StringEntity.

      This option is available only when "Custom JSON Payload" is selected.

Request HeadersAdd name(s) and value(s) to the request header.
No Response Expected

Check if no response is expected so that even if there is a response, this tool will simply ignore it.

Using this option will also disable "store to form" and "store to workflow variable" properties.

Debug ModeShow relevant debug entries in the server log for debugging purposes.

Store To Form

Figure 2: Store to Form

NameDescription
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

Figure 3: Store to Workflow Variable

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




Notes On JSON Returned Data


Introduced in v5, the API Domain Whitelist setting in General Settings needs to be configured to allow JSON API requests. If a request is from a non-whitelisted domain, the response will be a HTTP 400 Bad Request. Enter asterisk " * " into the API Domain Whitelist field in General Settings to allow API calls.


In figure 2 and 3 above, you can specify how to treat the returned data. The returned data may be saved as form data or/add to be saved into process's workflow variable. The example used in this article shows how one can store multi-row data into a form data table.

Sample JSON API POST call: http://localhost:8080/jw/web/json/apps/published/userviews 


{
	"apps": [
		{
			"name": "App Center",
			"userviews": [
				{
					"name": "Joget DX",
					"id": "v",
					"version": 1,
					"url": "/jw/web/userview/appcenter/v"
				},
				{
					"name": "Joget DX Platform",
					"id": "v2",
					"version": 1,
					"url": "/jw/web/userview/appcenter/v2"
				}
			],
			"id": "appcenter",
			"version": 1
		},
		{
			"name": "Customer Relationship Management",
			"userviews": [
				{
					"imageUrl": "/jw/web/app/crm/resources/crm_icon.png",
					"name": "Customer Relationship Management",
					"id": "crm_userview_sales",
					"version": 1,
					"url": "/jw/web/userview/crm/crm_userview_sales"
				}
			],
			"id": "crm",
			"version": 1
		}
	]
}





Download Demo App

Figure 4: Download the demo app below to view how JSON API is used in run process to populate form records


Should you encounter error as below : Please do " Setting Up SSL on Tomcat" to resolve the issue.

javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

The error above indicates that the Joget instance does not have any SSL cert installed or has an invalid SSL cert (e.g.: expired cert, improper SSL cert installation, etc.). Typically most public services will enforce mandatory HTTPS, this includes Github APIs.

The Joget server requires a valid SSL cert installed into the web app server's java keystore.

Here are some general guides you can refer to:

Do note that SSL setup steps may differ depending on several factors, such as your chosen SSL provider, proxy server used if any (e.g.: Apache HTTPD), operating system, etc.

Related Documentation