What is the correct way to pass a JSON body parameter to an API in TIBCO Data Virtualization 8.8.0?

What is the correct way to pass a JSON body parameter to an API in TIBCO Data Virtualization 8.8.0?

book

Article ID: KB0070004

calendar_today

Updated On:

Products Versions
TIBCO Data Virtualization 8.8.0

Description

This article assumes that the API server requires a JSON input and that the user has added the API as a REST data source in TIBCO Data Virtualization 8.8.0.

In earlier versions of TIBCO Data Virtualization, prior to 8.8.0, the implementation responsible for handling JSON parameters did not fully adhere to standard JSON handling practices. This allowed any invalid JSON body to work without issues, and TIBCO Data Virtualization would not raise any errors. However, starting with version 8.8.0, due to changes in the source code, the same parameter values that worked in earlier versions may no longer work. Instead, they will result in errors such as the following:

Error [data--1]: Expected a ':' after a key at character 11 of <parameter value>

Environment

All supported environments.

Resolution

Suppose a sample API expects the following inputs:
User-added image

In this case, the 'query' parameter is used to pass the JSON body to the API server.

User-added image
 

Let's test some sample JSON bodies being passed to the API server and review their results.


1) Passing the query as an invalid JSON :- {image/png}
-> This errors out as 
User-added image

As observed, this is not a valid JSON and hence errors out.

Note: The validity of any JSON can be checked at https://jsonlint.com/

2) Passing a valid JSON i.e. with key and value:- {"pkg.query":"{image/png}"}
User-added image
User-added image

A valid JSON body will always produce the correct result, assuming all other aspects of the API call are handled properly.

3) If the user wants to use the same JSON value as in point #1, i.e., {image/png}, there is a workaround: simply add a space character before the parameter.
User-added image

In this case, there is a space in front of the invalid JSON body. The reason that adding a space before the query works is due to specific logic implemented in the code. If the input does not begin with } or {{}{}, it is processed by a separate logic path that handles queries. This design ensures that queries are routed through the original code handling mechanism.

Please be advised that it is recommended to follow the standard and valid JSON body inputs and avoid relying on the workaround, as it may not be supported in future releases of TDV.

Issue/Introduction

This article explains the correct way to pass a JSON parameter as a body to an API in TIBCO Data Virtualization 8.8.0

Additional Information

https://docs.tibco.com/pub/tdv/8.8.0/TIB_tdv_8.8.0_relnotes.pdf?id=1