Passing API templates

In REST requests, the _templateKey and _templateId parameters reference templates that are stored in the database. Because the templates are accessed by reference, REST requests that use templates are lightweight, and multiple users can share a single centrally managed template.

Managing templates in the database

You can create, read, update, and delete API templates with three APIs. For detailed information about these APIs, view the API Javadoc files.

  • manageApiTemplate
  • getApiTemplateDetails
  • getApiTemplateList

You can access "ApiTemplate" APIs by specifying the resource name api_template in REST Detail, List, Modify, Create, or Delete requests.

The following example shows a REST Create request for an API template:
POST https://host:port/contextRoot/restapi/api_template

After a template is created in the database, its data is stored in the PLT_API_TEMPLATE table:

Entry Description
ORGANIZATION_CODE Organization identifier that is used in multi-tenant architectures

00 for an API template

01 for Resource

API_NAME Name of the API or Resource
TEMPLATE_ID Identifier within the org+type+name
DESCRIPTION Extra description information
TEMPLATE_DATA Character Large Object column that contains the template

Referencing templates

Request specific templates in any API call in the YFSEnvironment with the method:
public void setApiTemplate(String apiName, String templateFileName)
To reference a template from the REST layer, use a query parameter that matches the format of templateFileName:
templateFileName format REST query parameter format
"key:primaryKey" _templateKey=primaryKey
"id:orgCode,templateId" _templateId=orgCode,templateId
Note: The orgCode attribute is optional and defaults to DEFAULT.