Inserting RSD Parameters into an API Profile
Overview
Inserting RSD parameters into an API profile allows you to create generic RSDs, which can then be distributed to clients. This saves time by avoiding the need to create multiple RSDs, since all the parameters can simply be adjusted in the same RSD. The user can then use global variables or hard-coded values to adjust the parameters.
These parameters can have default values in the RSD files. If they don’t, errors will be displayed in DataSync requesting that you enter these value in the filter column of the extraction. The person creating the RSD defines which parameters have or do not have a default value.
Be careful when pre-populating an RSD with parameters and sending it. If the recipient is not using certain parameters and does not change their default values, they may accidentally point to another client’s information.
Implementation
First, you will need to have your RSD file correctly set up, then set the parameters up in the DataSync user interface. Below is an example of what a completed RSD file looks like with parameters:
<api:script xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:api="http://apiscript.com/ns?v1" >
<api:info title="CompanyStatus" desc="Returns the status of a company specified by its CompanyId." >
<attr name="CompanyId" xs:type="string" readonly="true" other:pseudocolumn="true" />
<attr name="Id" xs:type="string" readonly="true" other:xPath="id" key="true" />
<attr name="Title" xs:type="string" readonly="true" other:xPath="title" />
<attr name="Column1" xs:type="string" readonly="true" other:xPath="column1" />
<attr name="Column2" xs:type="string" readonly="true" other:xPath="column2" />
</api:info>
<!-- Setting global parameters -->
<api:set attr="ContentType" value="application/json" />
<api:validate attr="_input.CompanyId" desc="You must specify a CompanyId." />
<!-- Set authorization parameters -->
<!-- Using OAuth -->
<api:set attr="OAuthVersion" value="2.0" />
<api:validate attr="_connection.OAuthClientId" desc="OAuthClientId connection property should be specified for OAuth Authentication" />
<api:validate attr="_connection.OAuthClientSecret" desc="OAuthClientSecret connection property should be specified for OAuth Authentication" />
<api:validate attr="_connection.CallbackUrl" desc="CallbackUrl connection property should be specified for OAuth Authentication" />
<api:script method="GET" >
<api:set attr="method" value="GET" />
<api:validate attr="_connection.Deployment" desc="To query this table User is required to be specified in the connection string." />
<api:null attr="CompanyId">
<api:set attr="ColumnRequired" value="CompanyId" />
<api:push op="apisadoThrowColumnRequiredException" />
</api:null> <api:set attr="uri" value="https://sample.url.value/[_input.companyIds]" />
<api:set attr="RepeatElement" value="/response" />
<api:call op="apisadoExecuteJSONGet">
<api:push/>
</api:call>
</api:script>
</api:script>
Mandatory Parameters That Must be Changed to Your Specific Values
Define the validation for your Company ID. This also shows the error message displayed in DataSync if one is not specified:
<api:validate attr="_input.CompanyId" desc="You must specify a CompanyId." />
Allow the back-end to detect any missing parameters. This value is what allows the RSD to display an error if a parameter is missing:
<api:null attr="CompanyId">
<api:set attr="ColumnRequired" value="CompanyId" />
<api:push op="apisadoThrowColumnRequiredException" />
</api:null>
Use the parameters in the URL:
Use the parameters in the URL:
[_input.companyIds]
DataSync User Interface
When you arrive in the table screen of an RSD file that is missing parameters, it will display the message shown in the image below:
The mandatory parameters that are missing filters are easy to locate in the RSD, as their desc (i.e., description) will tell you that you must specify a parameter. Changing any value overrides the previous value.
Editing Fields
If you try to enter the fields section without having a value specified for all mandatory filters, you will see the following pop-up message indicating that there are mandatory filters missing:
To correct this, use the SQL Expression Builder of the filter column (shown below) to fill in the mandatory parameters.
You can also use variables to fill in the values of the parameters as shown below.
Visualization of data using the magnifying glass icon is disabled if there are mandatory filters missing.