API Connector for CData Sync

Build 22.0.8389
  • API
    • Establishing a Connection
    • Advanced Features
      • SSL Configuration
      • Firewall and Proxy
    • API Script Reference
      • Items in API Script
      • Value Formatters
        • String Formatters
        • Date Formatters
        • Math Formatters
      • Keyword Reference
        • api:break
        • api:call
        • api:case
        • api:catch
        • api:check
        • api:continue
        • api:default
        • api:else
        • api:enum
        • api:equals
        • api:exists
        • api:first
        • api:finally
        • api:if
        • api:include
        • api:info
        • api:last
        • api:map
        • api:match
        • api:notequals
        • api:null
        • api:notnull
        • api:push
        • api:script
        • api:select
        • api:set
        • api:setc
        • api:setm
        • api:throw
        • api:try
        • api:unset
        • api:validate
    • Connection String Options
      • Authentication
        • User
      • OAuth
        • OAuthVersion
        • OAuthClientId
        • OAuthClientSecret
      • SSL
        • SSLServerCert
      • Firewall
        • FirewallType
        • FirewallServer
        • FirewallPort
        • FirewallUser
        • FirewallPassword
      • Proxy
        • ProxyAutoDetect
        • ProxyServer
        • ProxyPort
        • ProxyAuthScheme
        • ProxyUser
        • ProxyPassword
        • ProxySSLType
        • ProxyExceptions
      • Logging
        • LogModules
      • Schema
        • Location
        • BrowsableSchemas
        • Tables
        • Views
      • APIProfile
        • Profile
        • ProfileSettings
      • APIServer
        • AuthScheme
        • Password
        • URL
      • Miscellaneous
        • MaxRows
        • Other
        • PseudoColumns
        • Timeout
        • UserDefinedViews

API Connector for CData Sync

Overview

The CData Sync App provides a straightforward way to continuously pipeline your API data to any database, data lake, or data warehouse, making it easily available for Analytics, Reporting, AI, and Machine Learning.

The API connector can be used from the CData Sync application to pull data from API and move it to any of the supported destinations.

API Connector for CData Sync

Establishing a Connection

Create a connection to API by navigating to the Connections page in the Sync App application and selecting the corresponding icon in the Add Connections panel. If the API icon is not available, click the Add More icon to download and install the API connector from the CData site.

Required properties are listed under the Settings tab. The Advanced tab lists connection properties that are not typically required.

The API Connector for CData Sync can be used to connect to a variety of data sources from within your application.

Connecting to Profiles

The Sync App can be used to connect to a variety of data sources, called Profiles, from within your application. An API profile is a collection of schemas modeling data from an application or online service as tables, views or stored procedures. API Profile files have the file exension ".apip" and can be download from the CData website.

To establish a connection using a Profile, set the Profile property to the path of the API profile file, and ProfileSettings to a connection string containing the credentials to the data-source. The most common forms of authentication are supported, including HTTP basic, HTTP digest, NTLM, and OAuth. For more information on the required connection properties, please refer to the documentation of each profile.

API Connector for CData Sync

Advanced Features

This section details a selection of advanced features of the API Sync App.

User Defined Views

The Sync App allows you to define virtual tables, called user defined views, whose contents are decided by a pre-configured query. These views are useful when you cannot directly control queries being issued to the drivers. See User Defined Views for an overview of creating and configuring custom views.

SSL Configuration

Use SSL Configuration to adjust how Sync App handles TLS/SSL certificate negotiations. You can choose from various certificate formats; see the SSLServerCert property under "Connection String Options" for more information.

Firewall and Proxy

Configure the Sync App for compliance with Firewall and Proxy, including Windows proxies and HTTP proxies. You can also set up tunnel connections.

Query Processing

The Sync App offloads as much of the SELECT statement processing as possible to API and then processes the rest of the query in memory (client-side).

See Query Processing for more information.

Logging

See Logging for an overview of configuration settings that can be used to refine CData logging. For basic logging, you only need to set two connection properties, but there are numerous features that support more refined logging, where you can select subsets of information to be logged using the LogModules connection property.

API Connector for CData Sync

SSL Configuration

Customizing the SSL Configuration

By default, the Sync App attempts to negotiate SSL/TLS by checking the server's certificate against the system's trusted certificate store.

To specify another certificate, see the SSLServerCert property for the available formats to do so.

API Connector for CData Sync

Firewall and Proxy

Connecting Through a Firewall or Proxy

HTTP Proxies

To connect through the Windows system proxy, you do not need to set any additional connection properties. To connect to other proxies, set ProxyAutoDetect to false.

In addition, to authenticate to an HTTP proxy, set ProxyAuthScheme, ProxyUser, and ProxyPassword, in addition to ProxyServer and ProxyPort.

Other Proxies

Set the following properties:

  • To use a proxy-based firewall, set FirewallType, FirewallServer, and FirewallPort.
  • To tunnel the connection, set FirewallType to TUNNEL.
  • To authenticate, specify FirewallUser and FirewallPassword.
  • To authenticate to a SOCKS proxy, additionally set FirewallType to SOCKS5.

API Connector for CData Sync

API Script Reference

The CData Sync App provides standards-based access to API by modeling local and remote data as relational tables, views, and stored procedures. CData has its own configuration language called API Script that you can use to mark up schemas. API Script hides the complexity of crafting requests to API and parsing the feeds returned.

However, API Script is also a high-level programming language that enables you to control almost every aspect of data access and processing. Your schema is a script interpreted by the API Script engine.

You use keywords, attributes, items, operations, and feeds to write scripts:

  • Attribute: The name part of a name-value pair, as in attribute="address", value="123 Pleasant Lane".
  • Item: A related group of attribute-value pairs that describe an input or output. For example:
    Attribute="name" value="Bob"
    Attribute="address" value="123 Pleasant Lane"
    Attribute="phone" value="123-4567"
  • Feed: A list of items: for example, a list of customers with their addresses and phone numbers.
  • Operation: A generic name for methods that accept items as input and produce feeds as output.
  • Keyword: An API Script statement, like api:set.
API Script includes many keywords that allow you to do the following:
  • Project columns over a feed and split feed items into rows.
  • Use high-level programming constructs such as if/else statements and case statements to control execution flow.
  • Call operations and define your own.
  • Create and modify items, the inputs to an operation, and feeds, the operation's result.
  • Process the feed resulting from an operation call by iterating through its items.

API Connector for CData Sync

Items in API Script

Feeds are composed of items, but in API Script items themselves are used for much more than the individual parts of a feed. They are also used to represent inputs to operations.

Declare Items

In API Script items are created, named, and given attribute values through the api:set keyword:

<api:set item="input" attr="mask" value="*.txt" />
The line above sets the "mask" attribute to the value "*.txt" on the item named "input". In this case, the input item is like a variable in API Script.

However, an item named "input" is never declared. Instead, the item is created the first time you try to set an attribute on it. In the example above, if the input item did not already exist, it would be created and the mask attribute would be set on it.

Select Attribute Values

To reference an attribute, use the syntax item.attribute (e.g., "input.mask"). To query an attribute value, surround the attribute name in square brackets ([]). This instructs the interpreter that you want to evaluate the string instead of interpreting it as a string literal.

For example, consider the following code snippet:

<api:set item="item1" attr="attr1" value="value1"/>
<api:set item="item1" attr="attr2" value="item1.attr1"/>
<api:set item="item1" attr="attr3" value="[item1.attr1]"/>

The results are the following:

  • item1.attr1 gets assigned the literal string value "value1".
  • item1.attr2 gets assigned the literal string value "item1.attr1".
  • item1.attr3 gets assigned the value "value1", because the string "[item1.attr1]" gets evaluated at run time as the attr1 attribute of item1.
Note that you can use a backslash to escape square brackets in string literals.

Default Item

In API Script there is always an implicit, unnamed item on an internal stack of items, the default item. In the following two cases, the default item is commonly used to make scripts shorter and easier to write:

  • Calling operations: The default item is the item passed by default to the operation called by your script if no other item is specified. This means that you can use api:set to write attributes to the default unnamed item and those attributes will be passed as input to the next operation called in the script. This is one way to provide an operation's required parameters.
  • Processing the current item in the output of an operation or script: If you do not specify a variable name for the result of an operation, then inside the api:call block that invokes the operation, the default item will refer to the current item produced by the operation.
Manipulate the default item by simply omitting the item attribute of an API Script keyword:
<api:set attr="path" value="." />

Named Items

In addition to items declared within the script, several built-in items are available in the scope of a script. Built-in, or special, items are available in API Script that provide an interface for accessing the connection string and the SQL query. These special items are useful for mapping inputs to data processing operations.

The following sections detail the special items.

Script Inputs (_input)

The input for a script can be read from the _input item. The SQL statement provides the input for table and stored procedure scehmas: In a SELECT statement, the _input item contains the columns or pseudo columns specified in the WHERE clause.

When you read values from the default item in a script, you are reading values from _input; likewise, attributes that you write to the default item are passed as parameters to operations along with the input to the script. Only the variables defined in the info block or in the script will be available in the _input item.

Note that inside an api:call block _input is no longer the default item and you must reference it by name if you need access to it.

Script Outputs (_out[n])

The current item in the feed produced by the api:call keyword can be accessed through the default item or a named special item, "_outX", where X is the level of nesting of api:call keywords. For example, if you are inside a single api:call keyword, the item's name will be "_out1". If you are inside three levels of nested api:call keywords, then it will be _out3.

Connection String Properties (_connection)

The _connection item has the connection properties of the Sync App. The Sync App does not perform any validation of the connection string properties. It is left to the schema author to decide which properties are required, how they are used, etc.

In addition to providing access to the connection properties, the _connection item can be used to store pieces of data in a connection. For example, it may be necessary to store session tokens that can be reused while a connection lasts. You can use the api:set keyword to store any values, as shown in the code example below:

<api:set attr="_connection._token" value="[oauth.connection_token]"/>

Note: You can set only the attributes that start with the _ symbol. This is done so that the connection properties set by the user cannot be overriden.

SQL Clauses (_query)

The _query item has the following attributes that describe the query that was issued to the Sync App:

queryThe SQL statement. For example:
SELECT Id, Name FROM Accounts WHERE City LIKE '%New%' AND COUNTRY = 'US' GROUP BY CreatedDate ORDER BY Name LIMIT 10,50;
selectcolumnsA comma-separated list of the columns in the SELECT clause. For example, the Id and Name columns in the example. If "*" is specified in the SELECT clause, the value of [_query.selectcolumns] is "*".
tableThe table name. For example, Accounts in the example.
isjoinWhether the query is a join.
jointableThe table in the JOIN clause.
criteriaThe WHERE clause. For example, the following WHERE clause in the example:
City LIKE '%New%' AND COUNTRY = 'US'
orderbyThe ORDER BY clause. For example, Name in the example.
groupbyThe GROUP BY clause. For example, CreatedDate in the example.
limitThe limit specified in the LIMIT or TOP clauses of the SELECT statement. For example, 50 in the example.
offsetThe offset specified in the LIMIT or TOP clauses of the SELECT statement. For example, 10 in the example.
insertselectThe SELECT statement nested in an INSERT statement.
updateselectThe SELECT statement nested in an UPDATE statement.
upsertselectThe SELECT statement nested in an UPSERT statement.
deleteselectThe SELECT statement nested in a DELETE statement.
bulkoperationcolumnsThe columns of the table the bulk operation modifies, separated by commas. For example, consider the following query:
INSERT INTO Account(account_name, account_type) SELECT customer_name, customer_type FROM Customer#TEMP
[_query.bulkoperationcolumns] returns the following:
[account_name], [account_type]
temptablecolumnsThe columns selected from the temp table in a bulk operation, separated by commas. For example, consider the following query:
DELETE FROM Account WHERE EXISTS SELECT customer_name, customer_type FROM Customer#TEMP
[_query.temptablecolumns] returns the following:
[customer_name], [customer_type]
nullupdatesThe columns of an UPDATE statement, separated by commas, that contain a null value or a null parameter value.
isschemaonlyWhether the query retrieves only schema information.

API Connector for CData Sync

Value Formatters

Value formatters enable you to generate new values with specific formatting. You can use value formatters to perform string, date, and math operations on values.

The general format for invoking formatters is

[ item.attribute | formatter(parameters) | formatter (parameters) | ...]
where formatter is the name of the formatter and parameters is an optional set of parameters to control formatter output. Formatter output can be provided as input to another formatter with the pipe character ("|").

Examples

  • In the following snippet any "*" character in the myid attribute's value is replaced by "-", and the resulting value is assigned to input1.id.
    <api:set attr="input1.id" value="[myid | replace('*', '-')]"/>
  • Below, two value formatters are chained with the pipe ("|") character. In the example, only .log files are pushed from the operation.
    <api:call op="fileListDir">
      <api:check attr="name" value="[filename|tolower | endswith('.log')]">
        <api:push/>
      </api:check>
    </api:call>

API Connector for CData Sync

String Formatters

[attr | allownull()]

Returns NULL if the attribute does not exist or the value if it does.

[attr | arrayfind(substring)]

Returns the index at which the string is found in the attribute array. The index is 1 based.

  • searchstring: The string to search for in the original value.

[attr | base64decode()]

Converts the attribute value to a base 64 decoded string.

[attr | base64encode()]

Converts the attribute value to a base 64 encoded string.

[attr | capitalize()]

Returns the original attribute value with only its first character capitalized.

[attr | capitalizeall()]

Returns the original attribute value with the first character of all words capitalized.

[attr | center(integer_width[, character])]

Returns the attribute value centered in a string of width specified by the first parameter. Padding is done using the fillchar specified by the second parameter.

  • width: The total width of the output string.
  • character: The optional character used for padding. If not specified this defaults to a space.

[attr | contains(value[, ifcontains][, ifnotcontains])]

Returns true (or ifcontains) if the attribute value contains the parameter value, false (or ifnotcontains) otherwise.

  • value: The string to find from the attribute value.
  • ifcontains: The optional value returned if the attribute value contains the parameter value.
  • ifnotcontains: The optional value returned if the attribute value does not contain the parameter value.

[attr | count(substring)]

Returns the number of occurrences in the attribute value of a substring specified by the first parameter.

  • substring: The substring to search for in the attribute value.

[attr | currency([integer_count])]

Returns the numeric value formatted as currency.

  • count: The optional number specifying how many places to the right of the decimal are displayed. The default is 2.

[attr | decimal([integer_count])]

Returns the numeric value formatted as a decimal number.

  • count: The optional number that indicates how many places to the right of the decimal are displayed. Default is 2.

[attr | def([notexists][, exists])]

Checks for the existence of an attribute and returns the specified parameter value if it does not.

  • notexists: The optional value to return if the attribute value does not exist.
  • exists: The optional value to return if the original attribute exists. If not specified, the original value of the attribute is returned.

[attr | empty(value)]

Returns the specified value if the attribute value is empty, otherwise the original attribute value.

  • value: The value that will be used if the attribute is empty.

[attr | endswith(substring[, iftrue][, iffalse])]

Determines whether the attribute value ends with the specified parameter. Returns true (or iftrue) if the attribute ends with the value and false (or iffalse) if not.

  • substring: The string expected at the end.
  • iftrue: The optional value returned if the attribute value ends with the parameter value.
  • iffalse: The optional value returned if the attribute value does not end with the parameter value.

[attr | equals(value[, ifequals][, ifnotequals])]

Compares the attribute value with the first parameter value and returns true (or ifequals) if they are equal and false (or ifnotequals) if they are not.

  • value: The string to compare with the attribute value.
  • ifequals: The optional value returned if the attribute value equals the value represented by the first parameter.
  • ifnotequals: The optional value returned if the attribute value does not equal the value represented by the first parameter.

[attr | extendtabs([integer_width])]

Replaces all tab characters found in the attribute value with spaces. If the tab size specified by the parameter is not given, a default tab size of 8 characters is used.

  • width: The optional tab width, defaults to 8 if not specified.

[attr | expr(expression)]

Evaluates the mathematical expression.

  • expression: The expression.

[attr | find(substring[, integer_startindex])]

Returns the lowest zero-based index at which the substring is found in the attribute value.

  • substring: The string to search for in the attribute value.
  • startindex: The optional index at which to start the search.

[attr | getlength()]

Returns the number of characters in the attribute value.

[attr | ifequal(value[, ifequals][, ifnotequals])]

Compares the attribute value with the first parameter value and returns true (or ifequals) if they are equal and false (or ifnotequals) if they are not.

  • value: The string to compare with the attribute value.
  • ifequals: The optional value returned if the attribute value equals the value represented by the first parameter.
  • ifnotequals: The optional value returned if the attribute value does not equal the value represented by the first parameter.

[attr | ifmatches(value[, ifmatch][, ifnotmatch])]

Returns true (or ifmatch) if the attribute value matches the first parameter, otherwise false (or ifnotmatch).

  • value: The value that will be compared with the attribute value.
  • ifmatch: The optional value returned if the attribute value matches the parameter value.
  • ifnotmatch: The optional value returned if the attribute value does not match the parameter value.

[attr | iftrue([iftrue][, iffalse])]

Checks the attribute value and returns true (or iftrue) if true and false (or iffalse) if false.

  • iftrue: The optional value returned if the attribute value is true.
  • iffalse: The optional value returned if the attribute value is false.

[attr | implode([separator])]

Implodes multiple values to a string separated by a separator.

  • separator: The optional separator.

[attr | insert(integer_index, string)]

Inserts the specified string at the specified index.

  • index: The zero-based index of the position in the original value where the new string should be inserted.
  • string: The string to insert into the original value.

[attr | isalpha([ifalpha][, ifnotalpha])]

Returns true (or ifalpha) if all characters in the attribute value are alphabetic and there is at least one character, false (or ifnotalpha) otherwise.

  • ifalpha: The optional value returned if the attribute value is alphabetic.
  • ifnotalpha: The optional value returned if the attribute value is not alphabetic.

[attr | isalphabetic([ifalpha][, ifnotalpha])]

Returns true (or ifalpha) if all characters in the attribute value are alphabetic and there is at least one character, false (or ifnotalpha) otherwise.

  • ifalpha: The optional value returned if the attribute value is alphabetic.
  • ifnotalpha: The optional value returned if the attribute value is not alphabetic.

[attr | isalphanum([ifalphanum][, ifnotalphanum])]

Returns true (or ifalphanum) if all characters in the attribute value are alphanumeric and there is at least one character, false (or ifnotalphanum) otherwise.

  • ifalphanum: The optional value returned if the attribute value contains only alphabetic or numeric characters.
  • ifnotalphanum: The optional value returned if the attribute value contains nonalphabetic or nonnumeric characters.

[attr | isalphanumeric([ifalphanum][, ifnotalphanum])]

Returns true (or ifalphanum) if all characters in the attribute value are alphanumeric and there is at least one character, false (or ifnotalphanum) otherwise.

  • ifalphanum: The optional value returned if the attribute value contains only alphabetic or numeric characters.
  • ifnotalphanum: The optional value returned if the attribute value contains nonalphabetic or nonnumeric characters.

[attr | isdigit([ifnum][, ifnotnum])]

Returns true (or ifnum) if all characters in the attribute value are digits and there is at least one character, false (or ifnotnum) otherwise.

  • ifnum: The optional value returned if the attribute value is numeric.
  • ifnotnum: The optional value returned if the attribute value is not numeric.

[attr | islower([iflower][, ifnotlower])]

Returns true (or iflower) if all letters in the attribute value are lowercase and there is at least one character that is a letter, false (or ifnotlower) otherwise.

  • iflower: The optional value returned if the attribute value is lowercase.
  • ifnotlower: The optional value returned if the attribute value is not lowercase.

[attr | isnumeric([ifnum][, ifnotnum])]

Returns true (or ifnum) if all characters in the attribute value are digits and there is at least one character, false (or ifnotnum) otherwise.

  • ifnum: The optional value returned if the attribute value is numeric.
  • ifnotnum: The optional value returned if the attribute value is not numeric.

[attr | isspace([ifspace][, ifnotspace])]

Return true (or ifspace) if there are only white-space characters in the attribute value and there is at least one character, false (or ifnotspace) otherwise.

  • ifspace: The optional value returned if the attribute value is a space.
  • ifnotspace: The optional value returned if the attribute value is not a space.

[attr | isupper([ifupper][, ifnotupper])]

Returns true (or ifupper) if all letters in the attribute value are uppercase and there is at least one character that is a letter, false (or ifnotupper) otherwise.

  • ifupper: The optional value returned if the attribute value is uppercase.
  • ifnotupper: The optional value returned if the attribute value is not uppercase.

[attr | join([separator])]

Implodes multiple values to a string separated by a separator.

  • separator: The optional separator.

[attr | jsonescape()]

Converts the attribute value to a JSON-escaped, single-line string.

[attr | just(integer_width[, character])]

Returns the attribute value left-justified in a string of length specified by the first parameter. Padding is done using the fillchar specified by the second parameter.

  • width: The total width of the output string.
  • character: The optional character used for padding. The default is a space.

[attr | lfind(substring[, integer_startindex])]

Returns the lowest zero-based index at which the substring is found in the attribute value.

  • substring: The string to search for in the attribute value.
  • startindex: The optional index at which to start the search.

[attr | ljust(integer_width[, character])]

Returns the attribute value left-justified in a string of length specified by the first parameter. Padding is done using the fillchar specified by the second parameter.

  • width: The total width of the output string.
  • character: The optional character used for padding. The default is a space.

[attr | lsplit(delimiter, integer_index)]

Splits the string represented by the attribute value into tokens delimited by the first parameter and returns the token at the index specified by the second parameter; counts from the left.

  • delimiter: The string used as a separator for splitting the string into tokens.
  • index: The index of the token requested where the first token is at index 1.

[attr | match(pattern[, index][, option])]

Searches the string represented by the attribute value for an occurrence of the regular expression supplied in the pattern parameter.

  • pattern: The regular expression pattern to match.
  • index: The optional numbered index of the match to return. The default is 0.
  • option: The optional comma-separated list of regular expression options. Some of the commonly used options are IgnoreCase, Multiline, Singleline, and IgnorePatternWhitespace.

[attr | md5hash([converttobase64])]

Computes the MD5 hash of the attribute value.

  • encodetobase64: The optional boolean value that specifies whether to convert the result into a base 64 encoded string. Default is true.

[attr | notequals(value[, notequals][, equals])]

Compares the attribute value with the first parameter value. Returns true (or notequals) if they are not equal and false (or equals) if they are.

  • value: The string to compare with the attribute value.
  • notequals: The optional value returned if the attribute value does not equal the value represented by the first parameter.
  • equals: The optional value returned if the attribute value equals the value represented by the first parameter.

[attr | nowhitespace()]

Removes the white space from the string represented by the atttribute value.

[attr | percentage([integer_count])]

Returns the numeric value formatted as a percentage.

  • count: The optional number that indicates how many places to the right of the decimal are displayed.

[attr | regex(pattern[, index][, option])]

Searches the string represented by the attribute value for an occurrence of the regular expression supplied in the pattern parameter.

  • pattern: The regular expression pattern to match.
  • index: The optional numbered index of the match to return. The default is 0.
  • option: The optional comma-separated list of regular expression options. Some of the commonly used options are IgnoreCase, Multiline, Singleline, and IgnorePatternWhitespace.

[attr | regexmatch(pattern[, index][, option])]

Searches the string represented by the attribute value for an occurrence of the regular expression supplied in the pattern parameter.

  • pattern: The regular expression pattern to match.
  • index: The optional numbered index of the match to return. The default is 0.
  • option: The optional comma-separated list of regular expression options. Some of the commonly used options are IgnoreCase, Multiline, Singleline, and IgnorePatternWhitespace.

[attr | regexreplace(search, replacewith[, integer_startat])]

Replaces all occurrences of the regular expression pattern found in the attribute value with replacewith.

  • search: The regular expression to search with.
  • replacewith: The text to replace the match with.
  • startat: The optional character index at which to start replacement. Default is 0.

[attr | remove(integer_index[, integer_count])]

Deletes characters from the attribute value; begins at the zero-based index specified by the first parameter.

  • index: The position to begin deleting the characters.
  • count: The optional number of characters to delete. If not provided all characters starting from the specified index will be deleted.

[attr | replace(oldvalue, newvalue[, ishex])]

Replaces all occurrences of the first parameter in the string represented by the attribute value with the value of the second parameter.

  • oldvalue: The string to be replaced.
  • newvalue: The string to replace all occurrences of the first parameter.
  • ishex: The optional boolean value specifying whether the first parameter is a hex representation of a character to replace. Default is false.

[attr | rfind(substring[, integer_startindex])]

Returns the highest zero-based index at which the substring is found in the attribute value.

  • substring: The string to search for in the original value.
  • startindex: The optional index at which to start the search.

[attr | rjust(integer_width[, character])]

Returns the right-justified attribute value in a string of length specified by the second parameter. Padding is done using the fillchar specified by the first parameter.

  • width: The total width of the output string.
  • character: The optional character used for padding, if not specified this defaults to a space.

[attr | rsplit(delimiter, integer_index)]

Splits the string represented by the attribute value into tokens delimited with the first parameter and returns the token at the index specified by the second parameter; counts from the right.

  • delimiter: The string used as a separator for splitting the string into tokens.
  • index: The index of the token requested where the first token is at index 1.

[attr | sha1hash([converttobase64])]

Computes the SHA-1 hash of the attribute value.

  • encodetobase64: The optional boolean value that specifies whether to convert the result into a base 64 encoded string. Default is true.

[attr | substring(integer_index[, integer_length])]

Returns a substring of the attribute value; starts at the index specified by the parameter and counts to the right.

  • index: The zero-based index at which the substring starts from the right.
  • length: The optional length of characters from the start index. The substring to the end is returned if length is not specified.

[attr | split(delimiter, integer_index)]

Splits the string represented by the attribute value into tokens delimited by the first parameter and returns the token at the index specified by the second parameter; counts from the left.

  • delimiter: The string used as a separator for splitting the string into tokens.
  • index: The index of the token requested where the first token is at index 1.

[attr | sqlescape()]

Converts the attribute value to an SQL-escaped, single-line string.

  • dbtype: The database type to encode. The allowed values are SQL or SQLite. Default is SQL.

[attr | startswith(substring[, iftrue][, iffalse])]

Returns true (or iftrue) if the attribute value starts with the specified parameter, false (or iffalse) otherwise.

  • substring: The string expected at the begining.
  • iftrue: The optional value returned if the attribute value starts with the parameter value.
  • iffalse: The optional value returned if the attribute value does not start with the parameter value.

[attr | striphtml()]

Returns the string with any HTML markup removed.

[attr | substring(integer_index[, integer_length])]

Returns a substring of the attribute value; starts at the index specified by the parameter.

  • index: The zero-based index at which the substring starts.
  • length: The optional length of characters from the start index. A substring to the end of the string is returned if length is not specified.

[attr | toalpha()]

Returns only the letters in a string.

[attr | toalphanum()]

Returns only the alphanumeric characters in a string.

[attr | tolower()]

Returns the string represented by the attribute value with all characters converted to lowercase.

[attr | toupper()]

Returns the string represented by the attribute value with all characters converted to uppercase.

[attr | trim()]

Trims leading and trailing white space from an attribute.

[attr | trimend()]

Trims trailing white space from an attribute.

[attr | trimstart()]

Trims leading white space from an attribute.

[attr | truncate(integer_count)]

Truncates the attribute value to the number of characters specified by the parameter.

  • count: The number of characters in the resulting string.

[attr | wordwrap([integer_width][, break][, cut][, wrapexp])]

Wraps a string to a given number of characters.

  • width: The optional number of characters at which the string will be wrapped.
  • break: The optional break parameter to be used to break the line.
  • cut: The optional boolean value that specifies whether to wrap the string at or before the specified width. Default is false.
  • wrapexp: The optional regex expression to be used as a breakable characters. Default is space.

[attr | print([delim])]

Returns a string with all the values of the attribute concatenated using the specified delimiter.

  • delim: The optional delimiter to separate values with. Default is a comma.

[attr | xmldecode()]

Converts the attribute value to a XML decoded string.

[attr | xmlencode()]

Converts the attribute value to a XML encoded string.

API Connector for CData Sync

Date Formatters

[attr | compare([value][, inputformat])]

Returns a signed number indicating the relative values of dates represented by the attribute value and parameter value.

  • value: The optional string representation of the date that will be compared with the attribute value. Default is now.
  • inputformat: The optional input format specifier. Default is autodetected.

[attr | date([outputformat])]

Returns the current system date and time in the format specified by the parameter if one was provided.

  • outputformat: The optional format specifier. Valid specifiers include d (short date pattern), D (long date pattern), f (long date/short time pattern), F (long date/time pattern), g (general short date/time pattern), G (general short date/long time pattern), r or R (RFC1123 pattern), s (sortable date/time pattern), t (short time pattern), T long time pattern), file (Windows file time), MM/dd/yy, etc.

[attr | dateadd([interval][, integer_value][, outputformat][, inputformat])]

Returns a string value of the datetime that results from adding the specified number interval (a signed integer) to the specified date part of the date.

  • interval: The optional interval you want to add. Specify year, month, day, hour, minute, second, or millisecond.
  • value: The optional number of intervals you want to add. Can either be positive for dates in the future or negative for dates in the past.
  • outputformat: The optional output format specifier. Valid specifiers include d(short date pattern), D(long date pattern), f(long date/short time pattern), F(long date/time pattern), g(general short date/time pattern), G(general short date/long time pattern), r or R(RFC1123 pattern), s(sortable date/time pattern), t(short time pattern), T(long time pattern), file(Windows file time), MM/dd/yy, etc.
  • inputformat: The optional input format specifier. Default is autodetected.

[attr | datediff([interval][, value][, inputformat])]

Returns the difference (in units specified by the first parameter) between now and the date specified by the second parameter.

  • interval: The optional interval you want the result in. Specify day, hour, minute, second, or millisecond.
  • value: The optional string representation of the date to compare with attribute value. Default is now.
  • inputformat: The optional input format specifier. Default is autodetected.

[attr | day([inputformat])]

Returns the day component, expressed as a value between 1 and 31, of the date represented by the attribute value.

  • inputformat: The optional input format specifier. Default is autodetected.

[attr | dayofweek([inputformat])]

Returns the day of week for the date represented by the attribute value.

  • inputformat: The optional input format specifier. Default is autodetected.

[attr | dayofyear([inputformat])]

Returns the day of year expressed as a value between 1 and 366 for the date represented by the attribute value.

  • inputformat: The optional input format specifier. Default is autodetected.

[attr | filetimenow()]

Returns the date and time for the current system file time.

[attr | fromfiletime([outputformat])]

Converts a valid file time to a valid datetime value formatted as specified by the parameter if one was provided.

  • outputformat: The optional output format specifier. Valid specifiers include d (short date pattern), D (long date pattern), f (long date/short time pattern), F (long date/time pattern), g (general short date/time pattern), G (general short date/long time pattern), r or R (RFC1123 pattern), s (sortable date/time pattern), t (short time pattern), T (long time pattern), file (Windows file time), MM/dd/yy, etc.

[attr | isleap([ifleap][, ifnotleap])]

Returns true (or ifleap) if the 4-digit year represented by the attribute value is a leap year, false (or ifnotleap) otherwise.

  • ifleap: The optional value returned if the attribute value is a leap year.
  • ifnotleap: The optional value returned if the attribute value is not a leap year.

[attr | month([inputformat])]

Returns the month component expressed as a value between 1 and 12 of the date represented by the attribute value.

  • inputformat: The optional input format specifier. Default is autodetected.

[attr | now([outputformat])]

Returns the current system date and time in the format specified by the parameter if one was provided.

  • outputformat: The optional format specifier. Valid specifiers include d (short date pattern), D (long date pattern), f (long date/short time pattern), F (long date/time pattern), g (general short date/time pattern), G (general short date/long time pattern), r or R (RFC1123 pattern), s (sortable date/time pattern), t (short time pattern), T long time pattern), file (Windows file time), MM/dd/yy, etc.

[attr | todate([outputformat][,inputformat])]

Returns the date specified by the attribute value formatted as specified by the parameter if one was provided.

  • outputformat: The optional output format specifier. Valid specifiers include d (short date pattern), D (long date pattern), f (long date/short time pattern), F (long date/time pattern), g (general short date/time pattern), G (general short date/long time pattern), r or R (RFC1123 pattern), s (sortable date/time pattern), t (short time pattern), T (long time pattern), file (Windows file time), MM/dd/yy, etc.
  • inputformat: The optional input format specifier. Default is autodetected.

[attr | tofiletime([inputformat])]

Converts a valid datetime to a valid file time value.

  • inputformat: The optional input format specifier. Default is autodetected.

[attr | tomonth()]

Returns the name of the month for the numeric value specified by the attribute value.

[attr | toutc([outputformat][, inputformat])]

Returns the date specified by the attribute value converted to UTC and formatted as specified by the outputformat parameter if one was provided.

  • outputformat: The optional format specifier. Valid specifiers include d (short date pattern), D (long date pattern), f (long date/short time pattern), F (long date/time pattern), g (general short date/time pattern), G (general short date/long time pattern), r or R (RFC1123 pattern), s (sortable date/time pattern), t (short time pattern), T (long time pattern), and file (Windows file time), MM/dd/yy, etc.

[attr | utcnow([outputformat])]

Returns the current system UTC date and time.

  • outputformat: The optional format specifier. Valid specifiers include d (short date pattern), D (long date pattern), f (long date/short time pattern), F (long date/time pattern), g(general short date/time pattern), G (general short date/long time pattern), r or R (RFC1123 pattern), s (sortable date/time pattern), t (short time pattern), T (long time pattern), file (Windows file time), MM/dd/yy, etc.

[attr | weekday([inputformat])]

Returns the day of the week as an integer where Monday is 0 and Sunday is 6.

  • inputformat: The optional input format specifier. Default is autodetected.

[attr | year([inputformat])]

Returns the year component of the date represented by the attribute value.

  • inputformat: The optional input format specifier. Default is autodetected.

API Connector for CData Sync

Math Formatters

[attr | abs()]

Returns the absolute value of the numeric attribute value.

[attr | add([value])]

Returns the sum of the numeric attribute value and the value specified by the parameter.

  • value: The optional numeric value to add to the specified attribute value. Default is 1.

[attr | and(value)]

Returns the AND of two values. The values provided on each side must be 1/0, yes/no or true/false.

  • value: The boolean value to compare by.

[attr | ceiling()]

Returns the smallest integer greater than or equal to a numeric attribute value.

[attr | div([value])]

Returns the result of dividing the numeric attribute value by the specified value of the parameter.

  • value: The optional numeric value to divide the numeric attribute value by. Default is 2.

[attr | divide([value])]

Returns the result of dividing the numeric attribute value by the specified value of the parameter.

  • value: The optional numeric value to divide the numeric attribute value by. Default is 2.

[attr | floor()]

Returns the largest integer less than or equal to the numeric attribute value.

[attr | greaterthan(value[, ifgreater][, ifnotgreater])]

Returns true (or ifgreater) if the attribute value is greater than the parameter value, false (or ifnotgreater) otherwise.

  • value: The numeric value to compare with the attribute value.
  • ifgreater: The optional value returned if the attribute value is greater than the parameter value.
  • ifnotgreater: The optional value returned if the attribute value is not greater than the parameter value.

[attr | isbetween(integer_lowvalue, integer_highvalue[, ifbetween][, ifnotbetween])]

Returns true (or ifbetween) if the attribute value is greater than or equal to the first parameter value and less than or equal to the second parameter value, false (or ifnotbetween) otherwise.

  • lowvalue: The lower bound of the range to check.
  • highvalue: The higher bound of the range to check.
  • ifbetween: The optional value returned if the attribute value is greater than or equal to the first parameter value and less than or equal to the second parameter value.
  • ifnotbetween: The optional value returned if the attribute value is less than the first parameter value or greater than the second parameter value.

[attr | isequal(value[, ifequal][, ifnotequal])]

Returns true (or ifequal) if the attribute value is equal to the parameter value, false (or ifnotequal) otherwise.

  • value: The numeric value to compare with the attribute value.
  • ifequal: The optional value returned if the attribute value is equal to the parameter value.
  • ifnotequal: The optional value returned if the attribute value is not equal to the parameter value.

[attr | isgreater(value[, ifgreater][, ifnotgreater])]

Returns true (or ifgreater) if the attribute value is greater than the parameter value, false (or ifnotgreater) otherwise.

  • value: The numeric value to compare with the attribute value.
  • ifgreater: The optional value returned if the attribute value is greater than the parameter value.
  • ifnotgreater: The optional value returned if the attribute value is not greater than the parameter value.

[attr | isless(value[, ifless][, ifnotless])]

Returns true (or ifless) if the attribute value is less than the parameter value, false (or ifnotless) otherwise.

  • value: The numeric value to compare with the attribute value.
  • ifless: The optional value returned if the attribute value is less than the parameter value.
  • ifnotless: The optional value returned if the attribute value is not less than the parameter value.

[attr | lessthan(value[, ifless][, ifnotless])]

Returns true (or ifless) if the attribute value is less than the parameter value, false (or ifnotless) otherwise.

  • value: The numeric value to compare with the attribute value.
  • ifless: The optional value returned if the attribute value is less than the parameter value.
  • ifnotless: The optional value returned if the attribute value is not less than the parameter value.

[attr | mathadd([value])]

Returns the sum of the numeric attribute value and the value specified by the parameter.

  • value: The optional numeric value to add to the specified attribute value. Default is 1.

[attr | mathmod(value)]

Returns the modulus of the numeric attribute value divided by the specified parameter value.

  • value: The number to divide the attribute value by.

[attr | mathpow([value])]

Returns the numeric attribute value raised to the power specified by the parameter value.

  • value: The optional power to raise the attribute value to. Default is 2.

[attr | mathround([integer_value])]

Returns the numeric attribute value rounded to the number of decimal places specified by the parameter.

  • value: The optional number of decimal places. Default is 2.

[attr | mathsub([value])]

Returns the difference between the numeric attribute value and the value specified by the parameter.

  • value: The optional numeric value to subtract the attribute value by.

[attr | modulus(value)]

Returns the modulus of the numeric attribute value divided by the specified parameter value.

  • value: The number to divide the attribute value by.

[attr | multiply([value])]

Returns the result of multiplying the numeric attribute value with the specified value of the parameter.

  • value: The optional numeric value to multiply the numeric attribute value by. Default is 2.

[attr | or(value)]

Returns the OR of two values. The values provided on each side must be 1/0, yes/no or true/false.

  • value: The boolean value to compare by.

[attr | pow([value])]

Returns the numeric attribute value raised to the power specified by the parameter value.

  • value: The optional power to raise the attribute value to. Default is 2.

[attr | rand([integer_value])]

Returns a random integer between 0 and the parameter value.

  • value: The optional value that limits the highest possible random integer. Default is 100.

[attr | random([integer_value])]

Returns a random integer between 0 and the parameter value.

  • value: The optional value that limits the highest possible random integer. Default is 100.

[attr | round([integer_value])]

Returns the numeric attribute value rounded to the number of decimal places specified by the parameter.

  • value: The optional number of decimal places. Default is 2.

[attr | sqrt()]

Returns the square root of the numeric attribute value.

[attr | subtract([value])]

Returns the difference between the numeric attribute value and the value specified by the parameter.

  • value: The optional numeric value to subtract the attribute value by.

API Connector for CData Sync

Keyword Reference

Statements in API Script are defined using keywords, XML elements prefixed with "api:". Keywords include the usual features of a programming or scripting language, such as conditionals, loops, and flow control. However, API Script also includes special keywords tailored specifically for feed manipulation and generation; for example, api:call, api:enum, and api:set.

Most keywords take parameters that define or affect their behavior. Parameters are specified as XML attributes of the keyword element. The required and optional parameters, along with code examples, for each keyword are explained in this section.

Keyword Scope

In API Script, some keywords introduce scope; that is, some keywords can be nested inside the bodies of other keywords, and how they are nested is meaningful to the language:

  • You can define instructions for an iteration within a keyword's scope: For example, the body of an api:call keyword is executed for each item in the feed produced by the operation invoked by api:call. Because of this, keywords nested inside api:call are executed for each iteration to produce each item in the feed.
  • Scope associates matching pairs of keywords; for example, the api:else keyword defines an alternate execution path for a conditional keyword like api:equals or api:check. In API Script, a certain api:else keyword is associated with a conditional statement when it is nested as a direct child of the conditional statement. Thus, the api:else keyword must not be defined outside of the scope introduced by a conditional keyword.
  • Keywords can introduce new items (variables) within their scope. For example, the api:call keyword will introduce a default output item representing the item being iterated over in the feed being generated.
  • Keywords can inject additional attributes into the default item that provide more information within their scope. These attributes are called Control Attributes when described in this document. They are easily recognized because they start with the _ character; for example, _attr, _index, _value, etc.

API Connector for CData Sync

api:break

The api:break keyword can be used to break out of iterations of api:call or api:enum. It can also be used to break out of the entire script if it is used outside the scope of any other API Script keywords.

Parameters

None

Control Attributes

None

Examples

Break out of api:enum. The example below lists the first two attributes of the item foo:

<api:set attr="foo.attr1" value="value1"/>
<api:set attr="foo.attr2" value="value2"/>
<api:set attr="foo.attr3" value="value3"/>

<api:enum item="foo">
[_index]: [_attr] has the value [_value]. 
<api:equals attr="_index" value="2"> 
<api:break/>
</api:equals>
</api:enum>

See Also

  • api:continue: Continue to the next item.
  • api:enum: Loop over the values of an item, list, range, or multivalued attribute.
  • api:call: Loop over items returned by an operation.

API Connector for CData Sync

api:call

The api:call keyword is used to call operations. Valid operations are the following:

  • Built-in operations installed along with Sync App assemblies located in the bin subfolder of the application
  • Operations you write yourself in .NET or Java and place in the bin subfolder of the application

Operations take items as input and return feeds as output. The scope of api:call is executed for every item in the feed returned from the call. Within the scope of api:call, you can inspect and modify the attributes in the item returned. You can then provide these attributes as inputs to another operation, thus forming an operation pipeline. Or, you can push out the item to the output.

The Output Item Stack and the Default Item

Each time an api:call is encountered, a new item is pushed onto an internal stack of items. The item on the top of this stack is the default item. This is the item that provides input to api:call when an item name is not explicitly specified in the input to the call.

The called operation writes attributes to the default item, and api:push pushes the default item to the output. When you push an item, only the attributes from the default item, at the top of the stack, are pushed.

The default item is swept clean after an item has been iterated over, and the api:call then works on the next item. This means that you will not be able to read a value set in a previous iteration of an api:call in the next iteration. To retain values across an iteration, copy them to a named item with api:set.

You can refer to the default item as _ or explicitly as _out1, _out2, _out[n], where N is the depth of the stack. This enables you to read all the values available at this point in the execution process; the lookup process starts from the default item and continues through the stack until a value is found.

In the example below, you can see how items are pushed to the top of the stack with each call and how the default item changes within the scope of each call.

<api:call op="operation1"> 
The default item here is _out1 
A push here would push the attributes from _out1 
The input item used to call operation2 is also _out1 
<api:call op="operation2"> 
The default item here is _out2 
A push here will push the attributes from _out2 
If there was another api:call here the input item used would be _out2 
_out2 is swept clean here for the next iteration 
</api:call> 
The default item here is again _out1 
A push here would again push the attributes from _out1 
The input item at this level is again _out1 
_out1 is swept clean here for the next iteration 
</api:call> 

Specify Input to an Operation

There are 3 ways to provide input to a call:

  • The default item: If an input item is not specified, the called operation reads input values from the default item. You can use the api:set keyword to set values in the default item so that they are processed by the called operation.
    <api:set attr="mask" value="*.txt"/>
    <api:set attr="path" value="C:\\"/>
    <api:call op="fileListDir">
    ... 
    </api:call>
  • An explicit input item: Instead of using the default item, you can use the in parameter to explicitly specify the items you want to use as input to the operation. If you choose to do so the default item is no longer used and the input values are read from the input items specified and, as shown below, the query string passed to the operation.
    <api:set attr="mask" value="*.* -- Will be ignored --"/>
    <api:set attr="myinput.mask" value="*.txt"/>
    <api:set attr="myinput.path" value="C:\\"/>
    <api:call op="fileListDir" in="myinput">
    ... 
    </api:call>
  • Query string parameters: You can also use query string notation to specify input to an operation. The attributes specified as part of the query string are given precedence. Thus, if there is a name clash between attributes specified in the query string and those in the input item, the ones in the query string are preferred. However, the other attributes of the input item are still accessible. The example below shows the syntax to specify input in the query string:
    <api:set attr="myinput.mask" value="*.txt -- will be overridden --"/> 
    <api:set attr="myinput.path" value="C:\\"/> 
    <api:call op="fileListDir?mask=*.rsb" in="myinput">
    ...
    </api:call>

Parameters

  • op: The name of the operation to be called.
  • in[put]: A list of items used as input when invoking the operation. Attributes are looked up from left to right in the input items specified.
  • out[put]: The item where the output attributes are placed. Within the api:call scope, the current output item can be retrieved using the item name specified here. You can also use _out[n] or _pipe to refer to the call's results.

    Note: Attributes set within a call are not available outside the scope of the call. This is because each iteration of the call deletes the attributes from the previous iteration; at the end of the call nothing is left. To access an attribute outside the scope of a call, use api:set to explicitly copy the attribute to the item you want to use outside the call.

  • item: The name of the item to be used for both input and output.
  • sep[arator]: The separator used to separate multiple input items. The default is a comma.
  • ignoreprefix: A comma-separated list of prefixes that are ignored when found. Some operations return attributes with names of the form "prefix:name" (e.g., api:operation and sql:company). In some situations, you may want to treat both prefix:name and name as the same attribute.
  • page and pagesize: The subset of items that will be iterated through. Used to enable paging of the operation or feed results. For example, if you specify page="2" and pagesize="5", the api:call keyword iterates only through items 6 to 10 of the resulting feed.

Control Attributes

  • _index: The index of the item currently being iterated over by api:call.
  • _op: The name of the operation being called. This is helpful when the operation name is not known until execution.
  • _separator: The separator used to separate multiple input items.

Examples

Call an operation using the default item as input:

<api:set attr="path" value="C:\myfiles"/>
<api:call op="fileListDir">
  <api:push/>
</api:call>

See Also

  • api:first: Write elements to be executed only for the first iteration of the call.
  • api:catch: Catch errors within a call.
  • api:continue: Continue to the next iteration.

API Connector for CData Sync

api:case

The api:case keyword is used with the api:select keyword. The api:case keyword consists of a block of API Script that is executed if the value in api:select matches the value in api:case.

Parameters

  • value: The pattern or value to compare against the value specified in api:select.
  • match: The type of matches to find to determine whether the case statement should be executed. The default value is "exact", which requires an exact match of the value. Other supported types are "regex", for regular expression matching, and "glob", which supports a simple expression model similar to the one used in file-name patterns (e.g., *.txt). The .NET edition of the Sync App uses the .NET Framework version of regular expression matching. The Java edition uses Java regular expression constructs.

Control Attributes

None

Examples

Display an icon based on the condition. The api:case elements match "CompanyA" and "CompanyB" in the company_name attribute and if any occurrences are found take the action associated with that case.

<api:select value="[company_name]">
  <api:case value="CompanyA">
    <img src="http://www.companya.com/favicon.ico" />
  </api:case>
  <api:case value="CompanyB">
    <img src="http://www.companyb.com/favicon.ico" />
  </api:case>
  <api:default>
    <img src="http://www.myhosting.com/generic.ico"/>
  </api:default>
</api:select>

See Also

  • api:select: Write a multiselect API Script block.
  • api:default: Write a default case for api:select.

API Connector for CData Sync

api:catch

The api:catch keyword is used to create an exception-handling block in a script. In addition to api:try, you can contain an api:catch block within any of the following keywords, the scope of which serves as an implicit api:try section:

  • api:call
  • api:script

Parameters

  • code: The code parameter allows you to selectively catch exceptions. To catch all exceptions, use the character *.

Control Attributes

  • _code: The code of the caught exception.
  • _desc: A short description of the caught exception.
  • _details: More information about the exception, if available.

Examples

Throw and catch an exception. Inside an api:call, an APIException is thrown and caught. Inside the scope of the keyword, the api:ecode and api:emessage attributes are added to the current item and pushed out.

<api:call op="...">
  <api:throw code="myerror" description="thedescription" details="Other Details."/>
  <api:catch code="myerror">
    <api:set attr="api:ecode" value="[_code]"/>
    <api:set attr="api:emessage" value="[_description]: [_details]"/>
    <api:push/>
  </api:catch>
</api:call>
Catch all exceptions:
<api:catch code="*">
  An exception occurred. Code: [_code], Message: [_desc]
</api:catch>

See Also

  • api:try: Define a scope to catch exceptions.
  • api:throw: Force an exception.

API Connector for CData Sync

api:check

The api:check keyword can be used with or without a value parameter. Without a value parameter, it is used to ensure that an attribute is present in an item and that it is not a null string before the body of the api:check is executed.

If a value parameter is specified, the api:check body executes only if the expression evaluates to true. Other values are considered false. The evaluation is case insensitive.

Like other simple conditionals in API Script, it can be paired with an api:else keyword. Note that, unlike api:equals, api:check does not throw an exception if the attribute does not exist in the item.

Parameters

  • item: The item in which to check the attribute. Specifying an item is not required. If no item is specified, the default output item is used instead.
  • attr: The name of the attribute to check. This parameter is required.
  • value: An expression that evaluates to true or false. For example, the result of a formatter that returns true or false.
  • action: The action to execute if the expression evaluates to true. Allowed values: break, continue.

Control Attributes

None

Examples

Check whether an attribute was set before using it:
<api:check attr="_input.In_Stock">
...
</api:check>

See Also

  • api:exists: Check if an attribute exists.
  • api:equals: Check for equality.
  • api:notequals: Check for inequality.

API Connector for CData Sync

api:continue

The api:continue keyword can be used to move to the next iterations of api:call or api:enum.

Parameters

None

Control Attributes

None

Examples

Produce a feed that lists only the files in a directory. The api:continue keyword is used to skip over items representing a directory.

<api:call op="fileListDir">
  <api:equals attr="file:isdir" value="true">
    <api:continue/>
  </api:equals>
  <api:push/>
</api:call>

List the values of single-valued attributes. All multivalued attributes are skipped by using api:continue.

<api:set attr="foo.multiattr#" value="value1"/>
<api:set attr="foo.multiattr#" value="value2"/>
<api:set attr="foo.attr2"      value="value3"/>
<api:enum item="foo">
  <api:notequals attr="_count" value="1">
    <api:continue/>
  </api:notequals>
  [_index]: [_attr] has the value [_value] <!-- only evaluated for attr2 -->
</api:enum>

See Also

  • api:break: Break out of api:call or api:enum iterations.
  • api:enum: Iterate over the values of an item, attribute, list, or range.
  • api:call: Call scripts, operations, or feeds.

API Connector for CData Sync

api:default

The api:default keyword is used with the api:select keyword. The api:default keyword consists of a block of API Script that is executed if the value in api:select does not match any of the values in api:case.

Parameters

None

Control Attributes

None

Examples

Display an icon based on the condition. The api:case elements match "CompanyA" and "CompanyB" in the company_name attribute, and, if any occurrences are found, take the action associated with that case.
<api:select value="[company_name]">
  <api:case value="CompanyA">
    <img src="http://www.companya.com/favicon.ico" />
  </api:case>
  <api:case value="CompanyB">
    <img src="http://www.companyb.com/favicon.ico" />
  </api:case>
  <api:default>
    <img src="http://www.myhosting.com/generic.ico"/>
  </api:default>
</api:select>

<p>

See Also

  • api:select: Write a multiselect API Script block.

API Connector for CData Sync

api:else

The api:else keyword is used to execute an alternate block of code when a test like api:exists or api:match fails. It can also be used to execute an alternate block of code within an api:call when the call fails to produce any output items.

Unlike other languages API Script requires the api:else statement to be within the scope of the test it belongs to.

Parameters

None

Control Attributes

None

Examples

Return a placeholder title if the file does not have a name:
<api:call op="fileListDir" out="out">
  <api:null attr="filename">
    <api:set attr="title" value="Unnamed File"/>
    <api:else>
      <api:set attr="title" value="[filename]"/>
    </api:else>
  </api:null>
  <api:push title="[title]">
  [out.*]
  </api:push>
</api:call> 

See Also

  • api:exists: Check if an attribute exists.
  • api:equals: Check for equality.

API Connector for CData Sync

api:enum

The api:enum keyword can be used to enumerate over the attributes within an item, a delimited list, a supplied range of values, and the values of a multivalued attribute. The body of api:enum is executed for each element of the set that is being iterated upon.

Parameters

  • item: The name of the item whose attributes you want to iterate over.
  • attr: The expression to match that specifies which attributes are iterated over. For example, "api:*". You can also provide this parameter to iterate over the values of a multivalued attribute.
  • prefix: The prefix based on which the item is enumerated.
  • expand: The boolean value that specifies how api:enum behaves when multivalued attributes are encountered. If expand is set to true, the body of api:enum will be executed once for each value of the attribute. If false, all values will be concatenated in a single string value, and only a single iteration will be performed. By default, api:enum will not expand all values.
  • sep[arator]: The separator to be used to concatenate values of a multivalued attribute if the expand parameter is false. Additionally, separator is used to tokenize the values in a list if listseparator is not defined. The default value is the new-line character "\n".
  • list: The list of separated values to enumerate over. For example, if the list of values is "violet, indigo, blue, green, yellow, orange, red" and the separator is a ',' the scope of api:enum is executed for each color in the rainbow.
  • range: The range of numbers or characters to enumerate over in ascending or descending order; for example, "a..z", "Z..A".
  • recurse: Whether to enumerate over nested attributes. The default is true.
Note: You can specify either the range attribute or the item attribute, but not both. Additionally, attributes are enumerated in alphabetical order.

Control Attributes

  • _attr: The name of the attribute being iterated over. When you are iterating over the values of a multivalued attribute, the attribute name will be the same except that it will also have the index as part of the name. The index is separated from the name by the hash symbol (#). For example, name#1, name#2, etc.
  • _index: The index at which the attribute appears within an item or the position of the list element currently being enumerated over.
  • _value: The value of the attribute being iterated over. For a multivalued attribute, the expand and separator parameter settings determine whether _value is a reference to one attribute value or a reference to all attribute values.
  • _count: The number of values in an attribute or in a list.
  • _separator: The separator used to separate the values in a list.

Examples

Display the attribute names and attribute values of the item named "input":

<api:set item="input" attr="Greeting" value="Hello" />
<api:set item="input" attr="Goodbye" value="See ya" />
<api:enum item="input">
  [_attr] is [_value]
  <br/>
</api:enum> 

goodbye is See ya greeting is Hello
To enumerate over a list of values use the list and separator parameters of api:enum. For example, the code below lists the colors specified in the colors attribute:
<api:set attr="colors" value="violet, indigo, blue, green, yellow, orange, red"/>
<api:enum list="[colors]" separator=",">
  [_value] 
</api:enum>
To enumerate over a range of values, use the range attribute. For example, the code below lists the character set from a to z, from Z to A, and the numbers from 1 to 25:
<api:enum range="a..z">
  [_value] 
</api:enum>
<api:enum range="Z..A">
  [_value] 
</api:enum>
<api:enum range="1..25">
  [_value] 
</api:enum>
To enumerate over all the values of a multivalued attribute, use the attr argument to specify a multivalued attribute and set expand to true:
<api:set attr="foo.email#1" value="[email protected]"/>
<api:set attr="foo.email#2" value="[email protected]"/>
<api:enum attr="foo.email" expand="true">
    ([_index]) [_attr] -> [_value]
</api:enum>
The example above results in the following output:
(1) email#1 -> [email protected] (2) email#2 -> [email protected]

See Also

  • api:break: Break out of api:call or api:enum iterations.
  • api:continue: Skip an api:call or api:enum iteration.
  • api:first: Provide special processing in the first iteration.
  • api:last: Provide special processing in the last iteration.

API Connector for CData Sync

api:equals

The api:equals keyword compares the value of an attribute to a reference value. Unlike api:check, the api:equals keyword will throw an exception if the specified item does not contain the specified attribute. If the specified attribute exists and its value matches, then the comparison will succeed.

Note: Both api:equals and api:check expect the name of the attribute whose value will be compared with a given value. If you need to compare two values, you can use api:select instead. For example:

<api:select value="[company_name]">
  <api:case value="CompanyA">
    <img src="http://www.companya.com/favicon.ico" />
  </api:case>
  <api:case value="CompanyB">
    <img src="http://www.companyb.com/favicon.ico" />
  </api:case>
  <api:default>
    <img src="http://www.myhosting.com/generic.ico"/>
  </api:default>
</api:select>

Parameters

  • item: The item in which to compare the attribute. Specifying an item is not required. If no item is specified, the default output item is used instead.
  • attr: The name of the attribute to compare.
  • case: Whether to use case-sensitive or case-insensitive comparison. This defaults to case-sensitive comparison; to use case-insensitive comparison, set the case parameter to "ignore".
  • value: The value to compare the attribute with.
  • action: The action to perform if equality is met. Allowed values: break, continue.

Control Attributes

None

Example

Like other conditional keywords, the body of api:equals may also contain an api:else keyword, which will be executed if the values do not match. The following lists all files except .err files:

<api:call op="fileListDir">
  <api:equals attr="file:extension" value=".err">
  <api:else>
    <api:push/>
  </api:else>
  </api:equals>
</api:call>

See Also

  • api:select: Choose between more than one alternative.
  • api:notequals: Create a block that is executed when equality is not met.

API Connector for CData Sync

api:exists

The api:exists keyword checks that an attribute has a value in the specified item. The api:notnull keyword is a synonym for api:exists.

Parameters

  • item: The item to check. If not specified, the default output item is used.
  • attr: The name of the attribute to check.
  • action: The action to perform if the expression evaluates to true. Allowed values: break, continue.

Control Attributes

None

Example

Define missing title attributes for a feed of files:
<api:call op="fileListDir" output="out">
  <api:exists attr="filename">
    <api:set attr="title" value="[filename]"/>
    <api:else>
      <api:set attr="title" value="Unnamed File"/>
    </api:else>
  </api:exists>
  <api:push title="[title]">
  [out.file:*] 
  </api:push>
</api:call> 

See Also

  • api:else: Create a block which is executed if the condition is not satisfied.

API Connector for CData Sync

api:first

The api:first keyword is used to execute a section of a script for only the first iteration of an api:call or api:enum keyword. It is a convenient way to generate headings or to inspect the first item of a feed before going through the rest of the feed.

During the first iteration, the api:first body executes before any other code within the api:call or api:enum, regardless of where the api:first is located within the api:call or api:enum body. As a reminder of this, it is recommended to locate the api:first at the top of the api:call or api:enum body.

If the scope has no items, then neither api:first nor api:last are executed.

Parameters

None

Control Attributes

None

Examples

Create an HTML table from a feed where each item is represented as a row:

<api:call op="listCustomers">
  <api:first>
    <table>
    <thead>
      <api:enum item="customer">
        <td>[_attr]</td>
      </api:enum>
    </thead>
  </api:first>
    <tr>
      <api:enum item="customer">
        <td>[_value]</td>
      </api:enum>
    </tr>
  <api:last>
    </table>
  </api:last>
</api:call>

See Also

  • api:last: Execute a code block only for the last iteration.

API Connector for CData Sync

api:finally

The api:finally keyword is used to execute a section of a script after control leaves an api:call, api:try, or api:script statement. It is a convenient way to clean up the formatting of generated documents.

Parameters

None

Control Attributes

None

Examples

The api:finally block is executed when an unhandled exception occurs. This can be used to ensure that tags are closed:

<table>
<api:call op="listCustomers" out="customer">
  <api:first>
    <thead>
        <api:enum item="customer">
          <td>[_attr]</td>
        </api:enum>
    </thead>
  </api:first>
  <tr>
      <api:enum item="customer">
        <td>[_value]</td>
      </api:enum>
  </tr>
  <api:finally>
  </table> <!-- ensure tags are still closed -->
  </api:finally>
</api:call>

See Also

  • api:try: Define a scope to catch exceptions.
  • api:call: Loop over items returned by an operation.
  • api:script: Create a script block.

API Connector for CData Sync

api:if

You can use the api:if keyword to evaluate expressions that can contain items, attributes, and values. The scope of the keyword is executed if the specified expression evaluates to true.

Parameters

  • exp: The expression to evaluate. You can make string, date, and numeric comparisons.
  • attr: The name of the attribute to compare the value of. The value of an attribute can be checked for a matching value or for the values null or notnull.
  • value: The value to compare with the value of the attribute specified by attr.
  • item: The item that contains the attribute being compared.
  • operator: The name of the operator to compare the operands specified by attr and value. Allowed values: null, notnull, hasvalue, equals, equalsignorecase, notequals, lessthan, and greaterthan. Default: notnull.
  • action: The action to perform if the expression evaluates to true. Allowed values: break, continue.

Control Attributes

None

Examples

Evaluate a simple comparison of two values:

<api:if exp="[attr] == 10">
Evaluate the equality of a given value and the value of a given attribute:
<api:set attr="attr1" value="value1"/>
<api:set attr="attr2" value="value2"/>
<api:if attr="attr1" value="[attr2]" operator="notequals"> <!-- Evaluates to true -->
<api:else>
False
</api:else>
True
</api:if>
Evaluate whether an attribute exists:
<api:set attr="exists" value="true"/>
<api:if attr="exists"> <!-- Evaluates to true -->
[exists]
</api:if>

See Also

  • api:exists: Check that an attribute has a value in the specified item.
  • api:equals: Create a block that is executed when equality is met.

API Connector for CData Sync

api:include

The api:include keyword is used to include API Script from other files. Like traditional includes in other programming languages, api:include is replaced by the contents of the file specified in the file parameter.

Parameters

  • file | document: The name of the file to be included.

Control Attributes

None

Examples

Import certain attributes (companyname, copyright) in each script without duplication:

<api:include file="globals.rsb"/> 
[companyname] 
[copyright] 
<api:call ...>

API Connector for CData Sync

api:info

The api:info keyword is used to describe the metadata for scripts. This information is used by the Sync App to implement basic error checking on user input and to set default values. The api:info keyword can contain the following:

  • Column definitions
  • Input parameters the script expects
  • Output the script produces

Table Parameters

The following parameters can be defined for the table itself:

  • desc[ription]: The description for the table. If a description is not provided, the name of the script is used.
  • title: The title of the script. If a title is not provided, the name of the script is used.
  • methods: The HTTP methods that can be executed against this script. SELECT, INSERT, UPDATE, and DELETE correspond to HTTP GET, POST, PUT/PATCH/MERGE, and DELETE, respectively.
  • url: The URL of the script author.
  • keywords: The keywords that describe the script.

Input, Output, and Column Parameters

The api:info keyword has additional parameters contained within its scope that define columns as well as script inputs and outputs. Note these parameters are not API Script keywords, but additional information for api:info.

attr

The attr parameter describes a table column and includes at least two attributes: name and data type. The name must be an alphanumeric string.

Other optional attributes provide more information about the column and enable the Sync App to represent these columns correctly in various tools.

<attr 
  name="Name"
  xs:type="string"
  other:xPath="name/full"
  readonly="true"    
  columnsize="100"
  desc="The name of the person." 
/> 

  • name: The alphanumeric string that defines the name of the column.
  • xs:type: The data type of the column. The string, int, double, datetime, and boolean types are supported.
  • other: Attributes prefixed with 'other:' that provide extra information. These other properties can be operation specific. For example, other:xPath specifies the XPath to a node in a local or remote resource. The XPath can be relative to a RepeatElement.
  • desc[ription]: A short description of the column.
  • key: Whether the column is part of the primary key in the table.
  • readonly: Whether the column can be updated. Allowed values are true and false.
  • req[uired]: Whether the column must be specified in an insert. Allowed values are true and false.
  • def[ault]: The default value for the column if none is specified.
  • values: A comma-separated list of the valid values for the column. If specified, the engine will throw an error if the specified column value does not match one of the allowed values.
  • reference[s]: The foreign key to the primary key of another table. The foreign key is specified with the following syntax: table.key. For example: "Employees.EmployeeId".
  • columnsize: The maximum character length of a string or the precision of a numeric column. The precision of a numeric column is the number of digits.
  • scale | decimaldigits: The scale of a decimal column. The scale is the number of digits to the right of the decimal point.
  • isnullable: Indicates whether the column accepts null values. Note that this does not prevent sending or receiving a null value.

input

Input parameters are used to describe inputs to the script.

Input elements can be used in schemas for both tables and stored procedures.

The attributes of this parameter provide users with more information about the input and allow the engine to perform rudimentary checks.

In stored procedure schemas, one or more input elements are used to describe the inputs of the stored procedure. In table schemas an input element defines a pseudo column, a column that can only be used in the WHERE clause.

For XML data sources, pseudo columns cannot contain an XPath.

<input
  name="name"
  desc="Example of an input parameter"
  default="defValue"
  req="true"
  values="value1, value2, value3"
  xs:type="string" 
/>
  • name: The name of the input. An alphanumeric string that may additionally contain the following: "#" denotes that the input can have multiple values, "myprefix:*" denotes a set of inputs with the same prefix, and a value of "*" denotes arbitrary input parameters.
  • desc[ription]: A short description of the input.
  • xs:type: The data type of the input. The string, int, double, datetime, and boolean types are supported.
  • def[ault]: The default value to be used when no input value is supplied in the script call.
  • key: Whether the input is a primary key.
  • req[uired]: Whether the input is required. The engine will throw an error if the required input is not supplied and there is no default value defined. Allowed values are true and false.
  • values: A comma-separated list of the allowed values for the input. If specified, the engine will throw an error if the specified input does not match one of the allowed values.
  • alias: The alias of the input.
  • other: Attributes prefixed with "other:" that provide extra information. These other properties can be operation specific.

output

Output parameters describe the output of the operation. However, they are ignored by the Sync App. Thus, the output of the operation can be entirely independent of what is defined in the info block.

<output  name="Id" 
         desc="The unique identifier of the record."
         xs:type="string"
         other:xPath="content/properties/Id" 
/>
  • name: The name of the output. "myprefix:*" denotes a set of outputs with the same prefix, and a value of "*" denotes arbitrary output parameters.
  • xs:type: The data type of the output. The string, int, double, datetime, and boolean types are supported.
  • desc[ription]: A short description of the output.
  • columnsize: The maximum character length of a string or the precision of a numeric output. The precision is the number of digits.
  • other: Attributes prefixed with 'other:' that provide extra information about the output. For example, other:xPath specifies the XPath to a node in a local or remote resource. The XPath can be relative to a RepeatElement.

Examples

Describes the metadata for a typical table with columns of different data types:
<api:info title="NorthwindOData" desc="Parse an XML document (NorthwindOdata.xml) into rows.">
  <attr name="ID"           xs:type="int" key="true" other:xPath="content/properties/ID" />
  <attr name="EmployeeID"   xs:type="int"            other:xPath="content/properties/EmployeeID" />
  <attr name="Name"         xs:type="string"         other:xPath="content/properties/Name" />
  <attr name="TotalExpense" xs:type="double"         other:xPath="content/properties/TotalExpense" />
  <attr name="HireDate"     xs:type="datetime"       other:xPath="content/properties/HireDate" />
  <attr name="Salary"       xs:type="int"            other:xPath="content/properties/Salary" />
</api:info> 

The following describes the metadata for a stored procedure that searches the Web using the Bing Search API:

<api:info title="SearchWeb"    desc="Use Bing to search the Web."> 
  <output name="Id"          xs:type="string"    other:xPath="content/properties/ID"          />
  <output name="URL"         xs:type="string"    other:xPath="content/properties/Url"         />
  <output name="Title"       xs:type="string"    other:xPath="content/properties/Title"       />
  <output name="Description" xs:type="string"    other:xPath="content/properties/Description" />
  <output name="DisplayURL"  xs:type="datetime"  other:xPath="content/properties/DisplayUrl"  />

  <input name="SearchTerms"    />
</api:info>

See Also

  • api:script: Create a script block.
  • api:call: Call scripts or operations.
  • api:set: Set attributes in an item.

API Connector for CData Sync

api:last

API Script keywords within the scope of the api:last keyword will only be executed after the last item is encountered and only if there were items returned by api:call or api:enum.

An api:last statement is executed only after the last item is processed; it maintains access to the last item in the feed. If the scope has no items, then neither api:first nor api:last are executed.

Parameters

None

Control Attributes

None

Examples

Create an HTML table from a feed where each item is represented as a row:

<api:call op="listCustomers">
  <api:first>
    <table>
    <thead>
      <api:enum item="customer">
        <td>[_attr]</td>
      </api:enum>
    </thead>
  </api:first>
  <tr>
    <api:enum item="customer">
      <td>[_value]</td>
    </api:enum>
  </tr>
  <api:last>
    </table>
  </api:last>
</api:call>

See Also

  • api:first: Execute a code block only for the first iteration.

API Connector for CData Sync

api:map

The api:map keyword is used to map attributes in one item to attributes in another item. Attributes are read from one item and written to another with the new names specified in the map string. The api:map keyword does not clear the destination item: It simply adds new attributes to it. Or, if an attribute exists in the destination item, it is overwritten, and other attributes remain as they were.

Parameters

  • to: The name of the item into which attributes are to be written.
  • from: The name of the item from which attributes are to be read.
  • map: A list of attribute names that specify the attribute names in the destination item, followed by the attribute names in the source item. For example, you can map attributes with one prefix to attributes with another prefix by using the syntax below:
    customer:* = soap:*
    Any characters that are not valid attribute names are ignored and are used to demarcate the end of a name.

Control Attributes

  • This keyword does not have any control attributes.

Examples

Map three attributes: The map is a succession of the "to" attribute name followed by the "from" attribute name.

<api:set item="item1" attr="var1" value="x"/>
<api:set item="item1" attr="var2" value="y"/>
<api:set item="item2" attr="attr1" value="z"/>
<api:map to="item2" from="item1" map="attr1=var1, attr2=var2"/>
In this example, the var1 and var2 attributes of item1 are mapped respectively to the attr1 and attr2 attributes of item2. The attr1 attribute, which is set in item2 with the value z, is overwritten with x, the value of var1 from item1. The attr2 attribute, which does not exist in item2, is created and set with y, the value of var2 in item1.

You can map multiple attributes from items with one prefix to items with a different prefix. This is useful in changing the prefix from Sync App prefixes (for example, soap:*) to business domain prefixes (for example, customer:*). The following example creates a mapping from all soap:* attributes in the item soapout to attributes prefixed with customer:* in the item customer:

<api:map from="soapout" to="customer" map="customer:* = soap:*"/>
Copy all attributes from one item to another item:
<api:map from="copyfrom" to="copyto" map="* = *"/>

See Also

  • api:set: Set the attributes of an item.

API Connector for CData Sync

api:match

The api:match keyword is similar to the api:equals keyword; however, it permits complex matching rules.

Parameters

  • pattern: The pattern to match.
  • type: The type of matches to find. The default value is "exact", which requires an exact match of the value. In this case api:match is identical to api:equals. Other supported types are "regex", for regular expression matching, and "glob", which supports a simple expression model similar to the one used in file-name patterns, for example, *.txt.

    The .NET edition of the Sync App uses the .NET Framework version of regular expression matching. The Java edition uses Java regular expression constructs.

  • value: The value to match.

Control Attributes

None

Examples

Check for floating point numbers using a regex pattern. If the pattern is matched then the item will be pushed out.

<api:match pattern="\[-+\]?\[0-9\]*\.?\[0-9\]*" type="regex" value="-3.14">
  <api:push/>
</api:match>

See Also

  • api:select: Compare multiple values.

API Connector for CData Sync

api:notequals

The api:notequals keyword verifies that the attribute does not match the specified value. It has a similar behavior to the api:equals keyword.

Parameters

  • item: The item in which to compare the attribute. Specifying an item is not required; if no item is specified, the default output item is used instead.
  • attr: The name of the attribute to compare.
  • value: The reference value to compare the attribute with.
  • action: The action to perform if the expression evaluates to true. Allowed values: break, continue.

Control Attributes

None

Example

List all files except .err files:
<api:call op="fileListDir">
  <api:notequals attr="file:extension" value=".err">
    <api:push/>
  </api:notequals>
</api:call>

See Also

  • api:equals: Check for equality.
  • api:else: Create a block which is executed if the condition is not satisfied.

API Connector for CData Sync

api:null

The api:null keyword checks that an attribute does not exist in the specified item.

Parameters

  • item: The item to check. If not specified, the default output item is used.
  • attr: The name of the attribute to check.
  • action: The action to perform if the expression evaluates to true. Allowed values: break, continue.

Control Attributes

None

Example

Define missing title attributes.
<api:call op="fileListDir" output="out">
  <api:null attr="filename">
    <api:set attr="title" value="Unnamed File"/>
    <api:else>
      <api:set attr="title" value="[filename]"/>
    </api:else>
  </api:null>
  <api:push title="[title]">
  [out.file:*] 
  </api:push>
</api:call>

See Also

  • api:else: Create a block which is executed if the condition is not satisfied.

API Connector for CData Sync

api:notnull

The api:notnull keyword checks that an attribute has a value in the specified item. The api:exists keyword is a synonym for api:notnull.

Parameters

  • item: The item to check. If not specified, the default output item is used.
  • attr: The name of the attribute to check.
  • action: The action to perform if the expression evaluates to true. Allowed values: break, continue.

Control Attributes

None

Example

Define missing title attributes.
<api:call op="fileListDir" output="out">
  <api:notnull attr="filename">
      <api:set attr="[title]" value="[filename]"/>
    <api:else>
      <api:set attr="[title]" value="Unnamed file"/>
    </api:else>
  </api:notnull> 
  <api:push title="[title]">
  [out.file:*]
  </api:push>
</api:call>

See Also

  • api:else: Create a block which is executed if the condition is not satisfied.

API Connector for CData Sync

api:push

The api:push keyword pushes an item into the output feed of the script. If there are no api:push elements in your script, no output items will result from it.

Parameters

  • item: The item to push into the feed. If not present, the item at the top of the stack will be pushed.
  • title: The title for the feed item.
  • desc[ription]: The description for the feed item. If none is provided, the scope of the api:push keyword will be used as the value of this attribute. The scope of the api:push keyword may contain other keywords, HTML tags, etc. Everything is evaluated as a template and is used to set the description.
  • op: The name of the operation to call and then push the resulting items. For example:
      <api:push op="myOp"/>    
      

    This is a shorthand for the following:

    <api:call op="myOp">
      <api:push/>
    </api:call>

  • enc[oding]: The encoding of the description. By default, the Sync App pushes the description as escaped XML. You can choose to encode the description as CDATA to include unescaped XML by setting this parameter to "cdata".

Control Attributes

None

Example

Create a description for each item pushed out. The description is the text within the scope of the api:push keyword, shown below:
<api:call op="fileListDir?mask=*.log">
  <api:push>
    The .log file contains details about the transmission, including any error messages.
  </api:push>
</api:call>

API Connector for CData Sync

api:script

The api:script keyword can be used to create script blocks that respond to SQL statements.

Parameters

  • method: The HTTP method (GET, POST, PUT/PATCH/MERGE, or and DELETE) used to invoke the script. Specify multiple methods in a comma-separated list. These methods correspond to SELECT, INSERT, UPDATE, and DELETE queries, respectively.

Control Attributes

None

Examples

Call two operations that manipulate remote API. This example uses an OData API, the odata.org Northwind reference service. In the example below, the first block will be executed only when the script is accessed using the POST method (an INSERT statement is executed), while the second block will be executed only when the script is accessed using the GET method (a SELECT statement is executed).

<api:script method="POST">
  <api:set attr="sql.rec:name" value="[_input.name]"/>
  <api:set attr="sql.rec:address" value="[_input.address]"/>
  <api:call op="sqliteInsert" in="sql">
    <api:push/>
  </api:call>
</api:script>
<api:script method="GET">
  <api:set attr="sql.query" value="SELECT * FROM [sql.table];"/>
  <api:call op="sqliteQuery" in="sql">
    <api:push/>
  </api:call>
</api:script>

API Connector for CData Sync

api:select

The api:select keyword is similar to a switch-case block in other programming languages and can be used to create complex conditional statements. The body of api:select can contain one or more api:case keywords and one api:default keyword.

The value in api:select is matched with those specified in api:case. The body of the api:case statement contains the keywords and statements to be executed if the value specified matches the value in the api:select keyword.

The body of the api:default statement will be executed only if none of the api:case statements result in a match. The api:default keyword has no parameters and can appear only once in an api:select.

Parameters

  • value: The value to compare with those specified in api:case statements.
  • attr: The attribute whose value is compared with values specified in api:case statements.

Control Attributes

None

Examples

Set the icon depending on the company name. The api:case elements match "CompanyA" and "CompanyB" in the company_name attribute, and, if any occurrences are found, take the action associated with that case.

<api:select value="[company_name]">
  <api:case value="CompanyA">
    <img src="http://www.companya.com/favicon.ico" />
  </api:case>
  <api:case value="CompanyB">
    <img src="http://www.companyb.com/favicon.ico" />
  </api:case>
  <api:default>
    <img src="http://www.myhosting.com/generic.ico"/>
  </api:default>
</api:select>

<p>

See Also

  • api:case: Write cases for api:select.
  • api:default: Write a default case for api:select.

API Connector for CData Sync

api:set

The api:set keyword sets a value in an attribute. If an attribute is set in an item that does not exist, the item is automatically created.

There are two ways to set a value using api:set. You can set the value parameter or, for large values that are multiline and complex, you can set the value using the scope of the keyword itself.

Parameters

  • item: The item parameter is used to specify the item in which the attribute is set. Specifying an item is not required. If an item is not specified, the default item is used.
  • attr: The name of the attribute. You can also specify the item using the dot notation (e.g., item.prefix:attr). Note that a complete attribute name has both a prefix and an attribute name, but the prefix is not required.
  • value: The value to be assigned to the attribute. If this parameter is not provided, the entire body of the api:set keyword is used as the value. This is convenient for setting long or multiline values.
  • copyfrom: The attributes from the item specified in this parameter are copied to the item specified by the item parameter.

Control Attributes

None

Examples

Use the scope of the keyword to set a value to the message attribute of the item named "input":

<api:set item="input" attr="message">
  Dear [name],
  You have won a cruise trip to Hawaii.
  Please confirm your acceptance by [date].
  Thanks, [sales]
</api:set>

See Also

  • api:unset: Remove an attribute from an item.
  • api:setm: Set multiple attributes with only one keyword.

API Connector for CData Sync

api:setc

The api:setc keyword enables you to add static text without escaping the special characters in API Script, such as square brackets. While special characters can be escaped with a backslash, this keyword provides a shortcut. For example, this keyword can be used to easily set an XPath.

Parameters

  • item: The item in which to set the attribute.
  • attr: The name of the attribute.
  • value: The value to be assigned to the attribute. If this parameter is not provided, the entire body of the api:setc keyword is used as the value. This is convenient for setting long or multiline values.
  • copyfrom: The attributes from the item specified in this parameter are copied to the item specified by the item parameter.

Control Attributes

None

Examples

Set an unescaped XPath:

<api:setc attr="xpath" value="/root/book[1]/@name" />

API Connector for CData Sync

api:setm

The api:setm keyword is a shorthand for api:set that can be used to perform multiple sets with just one keyword.

Each line, separated by \r\n, is a separate set operation. Multiline values can be specified with three single quotes ('''), as in Python.

The first equals sign ("=") separates the attribute name from the value. This means that attribute values can contain spaces. However, leading and trailing spaces are ignored. Quotes can be used to include leading or trailing spaces, as shown in the examples.

Parameters

  • item: The item in which the attributes are set. Specifying an item is not required. If an item is not specified, the default item is used.

Control Attributes

None

Examples

Use the scope of the keyword to set contact attributes:

<api:setm>
name = ContactName 
company = ContactCompany
address = 600 Market Street
includespace = " This string has a leading space"
</api:setm>

See Also

  • api:set: Set attributes in an item.

API Connector for CData Sync

api:throw

The api:throw keyword is used to raise an error (exception) from within a script.

Parameters

  • code: A string value used to identify the source or meaning of the exception. This parameter is required.
  • desc[ription]: An optional parameter that specifies a short message describing the error condition.
  • details: An optional parameter that can specify additional data useful to diagnose the error condition.

Control Attributes

None

Example

The example below explicitly defines both the error code and description:

<api:throw code="myerror" desc="thedescription" />

See Also

  • api:try: Define a scope for catching exceptions.
  • api:catch: Catch thrown exceptions and define exception processing.

API Connector for CData Sync

api:try

The api:try and api:catch keywords are used to create an exception-handling block in a script. If any keyword inside the api:try body throws an APIException, the Sync App will look for a matching api:catch keyword inside the same scope and will execute the catch body.

Parameters

None

Control Attributes

None

Example

Throw and catch an exception. Inside the scope of the keyword, api:ecode and api:emessage attributes are added to the current item and pushed out.

<api:call op="...">
  <api:try>
    <api:throw code="myerror" description="thedescription" details="Other Details."/>
    <api:catch code="myerror">
      <api:set attr="api:ecode" value="[_code]"/>
      <api:set attr="api:emessage" value="[_description]: [_details]"/>
      <api:push/>
    </api:catch>
  </api:try>
</api:call>

See Also

  • api:catch: Process thrown exceptions.
  • api:throw: Force an exception.

API Connector for CData Sync

api:unset

The api:unset keyword is used to delete attributes from an item or delete the item itself.

Parameters

  • item: The item from which the attribute is to be removed. If you do not specify an item, the default output item is used. This parameter can also be used to remove an item.
  • attr: The attributes to delete from the item. You can use a glob mask to delete more than one parameter, for example, "*.foo".

Control Attributes

None

Examples

Remove an attribute from an item before it is pushed out:

<api:call op="fileListDir">
  <api:unset attr="file:size"/>
  <api:push/>
</api:call>

See Also

  • api:set: Set attributes in an item.

API Connector for CData Sync

api:validate

You can use api:validate to throw an error if a required value is not provided.

Parameters

  • item: The item that contains the attribute to be validated.
  • attr: The attribute to be validated. If the attribute does not exist, an error is thrown.
  • code: The error code to be thrown if validation fails. Default: "api:validate".
  • desc: The error description to be thrown if validation fails. By default a message is thrown that the specified attribute is required.

Examples

Throw a more specific message if the _query item does not contain the Id attribute:

<api:validate attr="_query.Id"   desc="The Id is required to delete."/>

See Also

  • api:throw: Raise an error (exception) from within a script.

API Connector for CData Sync

Connection String Options

The connection string properties are the various options that can be used to establish a connection. This section provides a complete list of the options you can configure in the connection string for this provider. Click the links for further details.

For more information on establishing a connection, see Establishing a Connection.

Authentication


PropertyDescription
UserThe API user account used to authenticate.

OAuth


PropertyDescription
OAuthVersionThe version of OAuth being used.
OAuthClientIdThe client Id assigned when you register your application with an OAuth authorization server.
OAuthClientSecretThe client secret assigned when you register your application with an OAuth authorization server.

SSL


PropertyDescription
SSLServerCertThe certificate to be accepted from the server when connecting using TLS/SSL.

Firewall


PropertyDescription
FirewallTypeThe protocol used by a proxy-based firewall.
FirewallServerThe name or IP address of a proxy-based firewall.
FirewallPortThe TCP port for a proxy-based firewall.
FirewallUserThe user name to use to authenticate with a proxy-based firewall.
FirewallPasswordA password used to authenticate to a proxy-based firewall.

Proxy


PropertyDescription
ProxyAutoDetectThis indicates whether to use the system proxy settings or not. This takes precedence over other proxy settings, so you'll need to set ProxyAutoDetect to FALSE in order use custom proxy settings.
ProxyServerThe hostname or IP address of a proxy to route HTTP traffic through.
ProxyPortThe TCP port the ProxyServer proxy is running on.
ProxyAuthSchemeThe authentication type to use to authenticate to the ProxyServer proxy.
ProxyUserA user name to be used to authenticate to the ProxyServer proxy.
ProxyPasswordA password to be used to authenticate to the ProxyServer proxy.
ProxySSLTypeThe SSL type to use when connecting to the ProxyServer proxy.
ProxyExceptionsA semicolon separated list of destination hostnames or IPs that are exempt from connecting through the ProxyServer .

Logging


PropertyDescription
LogModulesCore modules to be included in the log file.

Schema


PropertyDescription
LocationA path to the directory that contains the schema files defining tables, views, and stored procedures.
BrowsableSchemasThis property restricts the schemas reported to a subset of the available schemas. For example, BrowsableSchemas=SchemaA,SchemaB,SchemaC.
TablesThis property restricts the tables reported to a subset of the available tables. For example, Tables=TableA,TableB,TableC.
ViewsRestricts the views reported to a subset of the available tables. For example, Views=ViewA,ViewB,ViewC.

APIProfile


PropertyDescription
ProfileThe profile property specifies the location on disk of the profile you would like to connect to.
ProfileSettingsA semicolon-separated list of name-value pairs required by your chosen data source, e.g.: username=myname; password=mypassword;appid=myapp.

APIServer


PropertyDescription
AuthSchemeThe scheme used for authentication. Accepted entries are None, NTLM, Basic or OAuth.
PasswordThe authtoken used to authenticate to the API Server.
URLThe API Server base resource url. For example, http://localhost:8153/api.rsc.

Miscellaneous


PropertyDescription
MaxRowsLimits the number of rows returned rows when no aggregation or group by is used in the query. This helps avoid performance issues at design time.
OtherThese hidden properties are used only in specific use cases.
PseudoColumnsThis property indicates whether or not to include pseudo columns as columns to the table.
TimeoutThe value in seconds until the timeout error is thrown, canceling the operation.
UserDefinedViewsA filepath pointing to the JSON configuration file containing your custom views.
API Connector for CData Sync

Authentication

This section provides a complete list of the Authentication properties you can configure in the connection string for this provider.


PropertyDescription
UserThe API user account used to authenticate.
API Connector for CData Sync

User

The API user account used to authenticate.

Remarks

Together with Password, this field is used to authenticate against the API server.

API Connector for CData Sync

OAuth

This section provides a complete list of the OAuth properties you can configure in the connection string for this provider.


PropertyDescription
OAuthVersionThe version of OAuth being used.
OAuthClientIdThe client Id assigned when you register your application with an OAuth authorization server.
OAuthClientSecretThe client secret assigned when you register your application with an OAuth authorization server.
API Connector for CData Sync

OAuthVersion

The version of OAuth being used.

Remarks

The version of OAuth being used. The following options are available: Disabled,1.0,2.0

API Connector for CData Sync

OAuthClientId

The client Id assigned when you register your application with an OAuth authorization server.

Remarks

As part of registering an OAuth application, you will receive the OAuthClientId value, sometimes also called a consumer key, and a client secret, the OAuthClientSecret.

API Connector for CData Sync

OAuthClientSecret

The client secret assigned when you register your application with an OAuth authorization server.

Remarks

As part of registering an OAuth application, you will receive the OAuthClientId, also called a consumer key. You will also receive a client secret, also called a consumer secret. Set the client secret in the OAuthClientSecret property.

API Connector for CData Sync

SSL

This section provides a complete list of the SSL properties you can configure in the connection string for this provider.


PropertyDescription
SSLServerCertThe certificate to be accepted from the server when connecting using TLS/SSL.
API Connector for CData Sync

SSLServerCert

The certificate to be accepted from the server when connecting using TLS/SSL.

Remarks

If using a TLS/SSL connection, this property can be used to specify the TLS/SSL certificate to be accepted from the server. Any other certificate that is not trusted by the machine is rejected.

This property can take the following forms:

Description Example
A full PEM Certificate (example shortened for brevity) -----BEGIN CERTIFICATE----- MIIChTCCAe4CAQAwDQYJKoZIhv......Qw== -----END CERTIFICATE-----
A path to a local file containing the certificate C:\cert.cer
The public key (example shortened for brevity) -----BEGIN RSA PUBLIC KEY----- MIGfMA0GCSq......AQAB -----END RSA PUBLIC KEY-----
The MD5 Thumbprint (hex values can also be either space or colon separated) ecadbdda5a1529c58a1e9e09828d70e4
The SHA1 Thumbprint (hex values can also be either space or colon separated) 34a929226ae0819f2ec14b4a3d904f801cbb150d

If not specified, any certificate trusted by the machine is accepted.

Use '*' to signify to accept all certificates. Note that this is not recommended due to security concerns.

API Connector for CData Sync

Firewall

This section provides a complete list of the Firewall properties you can configure in the connection string for this provider.


PropertyDescription
FirewallTypeThe protocol used by a proxy-based firewall.
FirewallServerThe name or IP address of a proxy-based firewall.
FirewallPortThe TCP port for a proxy-based firewall.
FirewallUserThe user name to use to authenticate with a proxy-based firewall.
FirewallPasswordA password used to authenticate to a proxy-based firewall.
API Connector for CData Sync

FirewallType

The protocol used by a proxy-based firewall.

Remarks

This property specifies the protocol that the Sync App will use to tunnel traffic through the FirewallServer proxy. Note that by default, the Sync App connects to the system proxy; to disable this behavior and connect to one of the following proxy types, set ProxyAutoDetect to false.

Type Default Port Description
TUNNEL 80 When this is set, the Sync App opens a connection to API and traffic flows back and forth through the proxy.
SOCKS4 1080 When this is set, the Sync App sends data through the SOCKS 4 proxy specified by FirewallServer and FirewallPort and passes the FirewallUser value to the proxy, which determines if the connection request should be granted.
SOCKS5 1080 When this is set, the Sync App sends data through the SOCKS 5 proxy specified by FirewallServer and FirewallPort. If your proxy requires authentication, set FirewallUser and FirewallPassword to credentials the proxy recognizes.

To connect to HTTP proxies, use ProxyServer and ProxyPort. To authenticate to HTTP proxies, use ProxyAuthScheme, ProxyUser, and ProxyPassword.

API Connector for CData Sync

FirewallServer

The name or IP address of a proxy-based firewall.

Remarks

This property specifies the IP address, DNS name, or host name of a proxy allowing traversal of a firewall. The protocol is specified by FirewallType: Use FirewallServer with this property to connect through SOCKS or do tunneling. Use ProxyServer to connect to an HTTP proxy.

Note that the Sync App uses the system proxy by default. To use a different proxy, set ProxyAutoDetect to false.

API Connector for CData Sync

FirewallPort

The TCP port for a proxy-based firewall.

Remarks

This specifies the TCP port for a proxy allowing traversal of a firewall. Use FirewallServer to specify the name or IP address. Specify the protocol with FirewallType.

API Connector for CData Sync

FirewallUser

The user name to use to authenticate with a proxy-based firewall.

Remarks

The FirewallUser and FirewallPassword properties are used to authenticate against the proxy specified in FirewallServer and FirewallPort, following the authentication method specified in FirewallType.

API Connector for CData Sync

FirewallPassword

A password used to authenticate to a proxy-based firewall.

Remarks

This property is passed to the proxy specified by FirewallServer and FirewallPort, following the authentication method specified by FirewallType.

API Connector for CData Sync

Proxy

This section provides a complete list of the Proxy properties you can configure in the connection string for this provider.


PropertyDescription
ProxyAutoDetectThis indicates whether to use the system proxy settings or not. This takes precedence over other proxy settings, so you'll need to set ProxyAutoDetect to FALSE in order use custom proxy settings.
ProxyServerThe hostname or IP address of a proxy to route HTTP traffic through.
ProxyPortThe TCP port the ProxyServer proxy is running on.
ProxyAuthSchemeThe authentication type to use to authenticate to the ProxyServer proxy.
ProxyUserA user name to be used to authenticate to the ProxyServer proxy.
ProxyPasswordA password to be used to authenticate to the ProxyServer proxy.
ProxySSLTypeThe SSL type to use when connecting to the ProxyServer proxy.
ProxyExceptionsA semicolon separated list of destination hostnames or IPs that are exempt from connecting through the ProxyServer .
API Connector for CData Sync

ProxyAutoDetect

This indicates whether to use the system proxy settings or not. This takes precedence over other proxy settings, so you'll need to set ProxyAutoDetect to FALSE in order use custom proxy settings.

Remarks

This takes precedence over other proxy settings, so you'll need to set ProxyAutoDetect to FALSE in order use custom proxy settings.

To connect to an HTTP proxy, see ProxyServer. For other proxies, such as SOCKS or tunneling, see FirewallType.

API Connector for CData Sync

ProxyServer

The hostname or IP address of a proxy to route HTTP traffic through.

Remarks

The hostname or IP address of a proxy to route HTTP traffic through. The Sync App can use the HTTP, Windows (NTLM), or Kerberos authentication types to authenticate to an HTTP proxy.

If you need to connect through a SOCKS proxy or tunnel the connection, see FirewallType.

By default, the Sync App uses the system proxy. If you need to use another proxy, set ProxyAutoDetect to false.

API Connector for CData Sync

ProxyPort

The TCP port the ProxyServer proxy is running on.

Remarks

The port the HTTP proxy is running on that you want to redirect HTTP traffic through. Specify the HTTP proxy in ProxyServer. For other proxy types, see FirewallType.

API Connector for CData Sync

ProxyAuthScheme

The authentication type to use to authenticate to the ProxyServer proxy.

Remarks

This value specifies the authentication type to use to authenticate to the HTTP proxy specified by ProxyServer and ProxyPort.

Note that the Sync App will use the system proxy settings by default, without further configuration needed; if you want to connect to another proxy, you will need to set ProxyAutoDetect to false, in addition to ProxyServer and ProxyPort. To authenticate, set ProxyAuthScheme and set ProxyUser and ProxyPassword, if needed.

The authentication type can be one of the following:

  • BASIC: The Sync App performs HTTP BASIC authentication.
  • DIGEST: The Sync App performs HTTP DIGEST authentication.
  • NEGOTIATE: The Sync App retrieves an NTLM or Kerberos token based on the applicable protocol for authentication.
  • PROPRIETARY: The Sync App does not generate an NTLM or Kerberos token. You must supply this token in the Authorization header of the HTTP request.

If you need to use another authentication type, such as SOCKS 5 authentication, see FirewallType.

API Connector for CData Sync

ProxyUser

A user name to be used to authenticate to the ProxyServer proxy.

Remarks

The ProxyUser and ProxyPassword options are used to connect and authenticate against the HTTP proxy specified in ProxyServer.

You can select one of the available authentication types in ProxyAuthScheme. If you are using HTTP authentication, set this to the user name of a user recognized by the HTTP proxy. If you are using Windows or Kerberos authentication, set this property to a user name in one of the following formats:

user@domain
domain\user

API Connector for CData Sync

ProxyPassword

A password to be used to authenticate to the ProxyServer proxy.

Remarks

This property is used to authenticate to an HTTP proxy server that supports NTLM (Windows), Kerberos, or HTTP authentication. To specify the HTTP proxy, you can set ProxyServer and ProxyPort. To specify the authentication type, set ProxyAuthScheme.

If you are using HTTP authentication, additionally set ProxyUser and ProxyPassword to HTTP proxy.

If you are using NTLM authentication, set ProxyUser and ProxyPassword to your Windows password. You may also need these to complete Kerberos authentication.

For SOCKS 5 authentication or tunneling, see FirewallType.

By default, the Sync App uses the system proxy. If you want to connect to another proxy, set ProxyAutoDetect to false.

API Connector for CData Sync

ProxySSLType

The SSL type to use when connecting to the ProxyServer proxy.

Remarks

This property determines when to use SSL for the connection to an HTTP proxy specified by ProxyServer. This value can be AUTO, ALWAYS, NEVER, or TUNNEL. The applicable values are the following:

AUTODefault setting. If the URL is an HTTPS URL, the Sync App will use the TUNNEL option. If the URL is an HTTP URL, the component will use the NEVER option.
ALWAYSThe connection is always SSL enabled.
NEVERThe connection is not SSL enabled.
TUNNELThe connection is through a tunneling proxy. The proxy server opens a connection to the remote host and traffic flows back and forth through the proxy.

API Connector for CData Sync

ProxyExceptions

A semicolon separated list of destination hostnames or IPs that are exempt from connecting through the ProxyServer .

Remarks

The ProxyServer is used for all addresses, except for addresses defined in this property. Use semicolons to separate entries.

Note that the Sync App uses the system proxy settings by default, without further configuration needed; if you want to explicitly configure proxy exceptions for this connection, you need to set ProxyAutoDetect = false, and configure ProxyServer and ProxyPort. To authenticate, set ProxyAuthScheme and set ProxyUser and ProxyPassword, if needed.

API Connector for CData Sync

Logging

This section provides a complete list of the Logging properties you can configure in the connection string for this provider.


PropertyDescription
LogModulesCore modules to be included in the log file.
API Connector for CData Sync

LogModules

Core modules to be included in the log file.

Remarks

Only the modules specified (separated by ';') will be included in the log file. By default all modules are included.

See the Logging page for an overview.

API Connector for CData Sync

Schema

This section provides a complete list of the Schema properties you can configure in the connection string for this provider.


PropertyDescription
LocationA path to the directory that contains the schema files defining tables, views, and stored procedures.
BrowsableSchemasThis property restricts the schemas reported to a subset of the available schemas. For example, BrowsableSchemas=SchemaA,SchemaB,SchemaC.
TablesThis property restricts the tables reported to a subset of the available tables. For example, Tables=TableA,TableB,TableC.
ViewsRestricts the views reported to a subset of the available tables. For example, Views=ViewA,ViewB,ViewC.
API Connector for CData Sync

Location

A path to the directory that contains the schema files defining tables, views, and stored procedures.

Remarks

The path to a directory which contains the schema files for the Sync App (.rsd files for tables and views, .rsb files for stored procedures). The folder location can be a relative path from the location of the executable. The Location property is only needed if you want to customize definitions (for example, change a column name, ignore a column, and so on) or extend the data model with new tables, views, or stored procedures.

If left unspecified, the default location is "%APPDATA%\\CData\\API Data Provider\\Schema" with %APPDATA% being set to the user's configuration directory:

API Connector for CData Sync

BrowsableSchemas

This property restricts the schemas reported to a subset of the available schemas. For example, BrowsableSchemas=SchemaA,SchemaB,SchemaC.

Remarks

Listing the schemas from databases can be expensive. Providing a list of schemas in the connection string improves the performance.

API Connector for CData Sync

Tables

This property restricts the tables reported to a subset of the available tables. For example, Tables=TableA,TableB,TableC.

Remarks

Listing the tables from some databases can be expensive. Providing a list of tables in the connection string improves the performance of the Sync App.

This property can also be used as an alternative to automatically listing views if you already know which ones you want to work with and there would otherwise be too many to work with.

Specify the tables you want in a comma-separated list. Each table should be a valid SQL identifier with any special characters escaped using square brackets, double-quotes or backticks. For example, Tables=TableA,[TableB/WithSlash],WithCatalog.WithSchema.`TableC With Space`.

Note that when connecting to a data source with multiple schemas or catalogs, you will need to provide the fully qualified name of the table in this property, as in the last example here, to avoid ambiguity between tables that exist in multiple catalogs or schemas.

API Connector for CData Sync

Views

Restricts the views reported to a subset of the available tables. For example, Views=ViewA,ViewB,ViewC.

Remarks

Listing the views from some databases can be expensive. Providing a list of views in the connection string improves the performance of the Sync App.

This property can also be used as an alternative to automatically listing views if you already know which ones you want to work with and there would otherwise be too many to work with.

Specify the views you want in a comma-separated list. Each view should be a valid SQL identifier with any special characters escaped using square brackets, double-quotes or backticks. For example, Views=ViewA,[ViewB/WithSlash],WithCatalog.WithSchema.`ViewC With Space`.

Note that when connecting to a data source with multiple schemas or catalogs, you will need to provide the fully qualified name of the table in this property, as in the last example here, to avoid ambiguity between tables that exist in multiple catalogs or schemas.

API Connector for CData Sync

APIProfile

This section provides a complete list of the APIProfile properties you can configure in the connection string for this provider.


PropertyDescription
ProfileThe profile property specifies the location on disk of the profile you would like to connect to.
ProfileSettingsA semicolon-separated list of name-value pairs required by your chosen data source, e.g.: username=myname; password=mypassword;appid=myapp.
API Connector for CData Sync

Profile

The profile property specifies the location on disk of the profile you would like to connect to.

Remarks

The Sync App enables you to connect to a variety of data sources by selecting a profile using the Profile property. The selected profile should be available in the configured Location.

API Connector for CData Sync

ProfileSettings

A semicolon-separated list of name-value pairs required by your chosen data source, e.g.: username=myname; password=mypassword;appid=myapp.

Remarks

The Sync App allows you to connect to a variety of data sources by selecting a profile using the Profile property. A profile may require other connection properties to function; these connection properties are determined by the profile author and can be specified via the ProfileSettings property.

API Connector for CData Sync

APIServer

This section provides a complete list of the APIServer properties you can configure in the connection string for this provider.


PropertyDescription
AuthSchemeThe scheme used for authentication. Accepted entries are None, NTLM, Basic or OAuth.
PasswordThe authtoken used to authenticate to the API Server.
URLThe API Server base resource url. For example, http://localhost:8153/api.rsc.
API Connector for CData Sync

AuthScheme

The scheme used for authentication. Accepted entries are None, NTLM, Basic or OAuth.

Remarks

Together with Password and User, this field is used to authenticate against the service. Basic is the default option.

  • NTLM: Set this to use your Windows credentials for authentication.
  • Basic: Set this to use HTTP Basic authentication.
  • Oauth: Set this to authenticate via OAuth.

API Connector for CData Sync

Password

The authtoken used to authenticate to the API Server.

Remarks

Authtokens are created in the API Server. To create an API Server user, click Settings -> Users in the API Server administration console.

API Connector for CData Sync

URL

The API Server base resource url. For example, http://localhost:8153/api.rsc.

Remarks

The API Server base resource url. For example, http://localhost:8153/api.rsc.

API Connector for CData Sync

Miscellaneous

This section provides a complete list of the Miscellaneous properties you can configure in the connection string for this provider.


PropertyDescription
MaxRowsLimits the number of rows returned rows when no aggregation or group by is used in the query. This helps avoid performance issues at design time.
OtherThese hidden properties are used only in specific use cases.
PseudoColumnsThis property indicates whether or not to include pseudo columns as columns to the table.
TimeoutThe value in seconds until the timeout error is thrown, canceling the operation.
UserDefinedViewsA filepath pointing to the JSON configuration file containing your custom views.
API Connector for CData Sync

MaxRows

Limits the number of rows returned rows when no aggregation or group by is used in the query. This helps avoid performance issues at design time.

Remarks

Limits the number of rows returned rows when no aggregation or group by is used in the query. This helps avoid performance issues at design time.

API Connector for CData Sync

Other

These hidden properties are used only in specific use cases.

Remarks

The properties listed below are available for specific use cases. Normal driver use cases and functionality should not require these properties.

Specify multiple properties in a semicolon-separated list.

Integration and Formatting

DefaultColumnSizeSets the default length of string fields when the data source does not provide column length in the metadata. The default value is 2000.
ConvertDateTimeToGMTDetermines whether to convert date-time values to GMT, instead of the local time of the machine.
RecordToFile=filenameRecords the underlying socket data transfer to the specified file.

API Connector for CData Sync

PseudoColumns

This property indicates whether or not to include pseudo columns as columns to the table.

Remarks

This setting is particularly helpful in Entity Framework, which does not allow you to set a value for a pseudo column unless it is a table column. The value of this connection setting is of the format "Table1=Column1, Table1=Column2, Table2=Column3". You can use the "*" character to include all tables and all columns; for example, "*=*".

API Connector for CData Sync

Timeout

The value in seconds until the timeout error is thrown, canceling the operation.

Remarks

If Timeout = 0, operations do not time out. The operations run until they complete successfully or until they encounter an error condition.

If Timeout expires and the operation is not yet complete, the Sync App throws an exception.

API Connector for CData Sync

UserDefinedViews

A filepath pointing to the JSON configuration file containing your custom views.

Remarks

User Defined Views are defined in a JSON-formatted configuration file called UserDefinedViews.json. The Sync App automatically detects the views specified in this file.

You can also have multiple view definitions and control them using the UserDefinedViews connection property. When you use this property, only the specified views are seen by the Sync App.

This User Defined View configuration file is formatted as follows:

  • Each root element defines the name of a view.
  • Each root element contains a child element, called query, which contains the custom SQL query for the view.

For example:

{
	"MyView": {
		"query": "SELECT * FROM NorthwindOData WHERE MyColumn = 'value'"
	},
	"MyView2": {
		"query": "SELECT * FROM MyTable WHERE Id IN (1,2,3)"
	}
}
Use the UserDefinedViews connection property to specify the location of your JSON configuration file. For example:
"UserDefinedViews", "C:\\Users\\yourusername\\Desktop\\tmp\\UserDefinedViews.json"

Copyright (c) 2022 CData Software, Inc. - All rights reserved.
Build 22.0.8389