This article explains connecting a Page or an RDLX report to a JSON data source. You can connect to this data source while creating a new report (via report wizard) or using report explorer (via report data source dialog).
The steps to connect to the JSON data source are:
Connection String |
Copy Code
|
---|---|
jsondoc=https://demodata.mescius.io/northwind/odata/v1/Orders
|
The Configuration Settings are explained in the next section.
The JSON Data Provider provides the following configuration settings under the Connection section in the Report Data Source dialog.
The Content tab describes the type of JSON data you want to use for connecting to a data source. The options available for specifying the JSON data are as follows:
The Schema tab describes the options available for specifying the JSON schema in ActiveReports.
The JSON schema describes the structure of the JSON data. In ActiveReports, the JSON data provider uses the JSON schema to obtain fields. For more information on JSON schema, please see https://json-schema.org/understanding-json-schema/.
JSON data provider does not support the following schema keywords, such as:
The Connection String tab displays the JSON connection string based on the defined configuration settings in the Content and Schema tab.
Connection String |
Copy Code
|
---|---|
jsondoc=C:\customers.json |
Connection String |
Copy Code
|
---|---|
jsondoc=https://demodata.mescius.io/northwind/odata/v1/Orders
|
Connection String |
Copy Code
|
---|---|
jsondata={"Customers":[{"Id":"ALFKI", "CompanyName":"Alfreds Futterkiste", "Country":"Germany"}, {"Id":"ANATR", "CompanyName":"Ana Trujillo Emparedados y helados", "Country":"Mexico"}], "ResponseStatus":{}} |
Connection String |
Copy Code
|
---|---|
="jsondata={ 'Name': 'Name'};schemadata={ '$schema': 'http://json-schema.org/draft-04/schema#', 'definitions': {}, 'id': 'http://example.com/example.json', 'properties': { 'Name': { 'id': '/properties/Name', 'type': 'string' } }, 'type': 'object'}"
|
For example, the following connection string is invalid:
Connection String (invalid) |
Copy Code
|
---|---|
="jsondata={ "Name": "Name"};schemadata={ "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {}, "id": "http://example.com/example.json", "properties": { "Name": { "id": "/properties/Name", "type": "string" } }, "type": "object"}" |
It is possible to configure the JSON data source connection string by using the Build button in the Connection String tab of the Report Data Source - General dialog. This allows fetching a JSON from an external URL using the specified method (GET, POST) and other request options. Clicking the Build button opens the Configure JSON Data Source dialog where you can create a JSON connection string with parameters such as data path, method (GET, POST), headers, and body.
To connect to a external URL containing JSON data, some settings are required to be configured as elaborated.
Data Path:
The URL or the endpoint of the request consists of service root URI, resource path, and query options. The fields from json provided in the data source's endpoint are extracted depending on the dataset’s settings. A URL with IP address (eg. http://10.64.2.17:51980/admin) or with a machine name (eg. http://in-esxi-w10v17:8080/) is also valid.
HTTP Headers:
Contains additional info related to the request or the response, for eg, provide expected content type necessary for establishing connection with endpoint which must return json. For example, providing credentials to login to a service/URI to retrieve data. Collection editor to add header/value pair for headers is available. This parameter has to be set to send the request body in JSON format.
Example of Header,Value pairs:
Content-Type, application-json (to send the request body in JSON format)
HTTP Method:
Request method can be GET (included in URL) or POST (included in 'body').
Request Body (POST):
Text area, applicable only in case of POST HTTP request.
You should provide a valid combination of configuration settings for the successful processing of the connection string with the POST method. If a combination of a valid URL, a valid header name, a valid header value, and a valid body is provided, then the connection string can be saved and validated. Only in this case, it is possible to create a dataset based on this data source.
If an invalid URL, an invalid header name or header value, invalid body, or a combination of these settings is entered, error message is displayed while validating the connection string.
Connection String |
Copy Code
|
---|---|
jsondoc=https://demodata.mescius.io/northwind/api/v1/Categories
|
Dataset Query |
Copy Code
|
---|---|
$.[*] |
To convert the format of data in the requested URI to JSON, use either $format query or Http Header as shown in the following connection strings:
Connection String |
Copy Code
|
---|---|
jsondoc=https://services.odata.org/v3/northwind/northwind.svc/Invoices?$format=json
|
Connection String |
Copy Code
|
---|---|
headers={"Accept":"application/json"};jsondoc=https://services.odata.org/v3/northwind/northwind.svc/Invoices |
Dataset Query |
Copy Code
|
---|---|
$.value[*] |
Connection String |
Copy Code
|
---|---|
headers={"Accept":"application/json"};jsondoc=https://services.odata.org/v3/northwind/northwind.svc/Invoices?$select=ShipName,ShipRegion |
Dataset Query |
Copy Code
|
---|---|
$.value[*] |
Connection String |
Copy Code
|
---|---|
headers={"Accept":"application/json"};jsondoc=https://services.odata.org/v3/northwind/northwind.svc/Invoices?$filter=ShipName eq 'Alfreds%20Futterkiste' |
Dataset Query |
Copy Code
|
---|---|
$.value[*] |