REST API Assets > REST API assets > Creating an API operation
  

Creating an API operation

Use the REST API page to create an operation for an API.
The following image shows the REST API page with the operations area selected and the operations panel displayed:
The page shows the REST API metadata area, policies area, expanded operations area with a POST operation selected and the operation panel for the POST operation.
  1. 1REST API metadata area. Define the metadata of the REST API asset.
  2. 2API Policies area. Configure the policies of the API.
  3. 3Operations area. Create operations.
  4. 4Operation panel. Define the metadata of an operation.
  5. 5Operation tabs. Define the parameters, request, and response, map an Application Integration process, and configure operational policies and a response timeout for an operation.
To create an operation, you perform the following tasks:
  1. 1Define the operation metadata.
  2. 2Define the operation parameters.
  3. 3Define the operation request.
  4. 4Define the operation response.
  5. 5Map an Application Integration process to the operation.
  6. 6Configure operational policies.
  7. 7Configure a response timeout.
Repeat the steps to create as many operations as needed for an API.

Step1. Define the operation metadata

Define the metadata of an API operation on the operation panel.
    1In the Operations area of the REST API page, click +, or on the right panel of the REST API page, click Create a New Operation.
    2In the Operation Name field, enter a name for the operation.
    The name must be between 2 and 28 characters, including ASCII letters, digits, and underscores.
    3Optionally, in the Description field, enter a description.
    4From the request methods list, select the request method.
    5In the Operation endpoint field, enter a URL in the following format: /{operation name}/{path parameter key}/
    The operation endpoint path must be unique for an HTTP verb.
    6Click Save.

Step 2. Define operation parameters

Define the parameters of an API operation on the Parameters tab of the operation panel.
    1On the operation panel, click Parameters.
    2Click +.
    3In the Key field, enter a name for the parameter.
    4From the Type list, select the parameter type.
    If you select Path, you can't add a value, the Required field is True by default and you can't change it. If you select Query, you can add a value, the Required field is True by default and you can change it.
    5From the Data Type list, select a data type.
    6Optionally, in the Description field, enter a description.
    7Add as many parameters to the operation as required. To delete a parameter, click Delete on the row of the parameter.
    8Click Save.

Step 3. Define the operation request

Define the operation request on the operation panel, including the header type and the request attributes. You can define the request body by adding attributes or by defining attributes in a JSON script.
    1On the operation panel, click Request.
    2In the Headers area, click +.
    3In the Name field, enter a name for the header.
    4From the type list, select a header type.
    5Optionally, in the Description field, enter a description.
    6Optionally, in the Default Value field, enter a value.
    7To add request body attributes, in the Body area, click +.
    8In the Field Name field, enter a name for the attribute. Assign a meaningful name, such as Order, Quantity, or Status.
    9From the Data Type list, select a data type. If you select Array, from the Array Type list, select an array type. If you select Object, you can add as many child objects or fields under it as required.
    10Optionally, in the Description field, enter a description.
    11Optionally, select Required to make the attribute required. By default, the attribute isn't required.
    12Click Add.
    13Add as many attributes to the request body as required. The order of the attributes determines their order in the request body. Move up or move down the attributes as needed. To delete a request header or an attribute, click the Actions menu on the row of the header or attribute and then click Delete.
    14To define the request attributes in a JSON script, click JSON and add the request body fields as required. You must provide the fields according to the JSON format displayed on the JSON tab.
    15Click Save.

Step 4. Define the operation response

Define the operation response on the operation panel, including the header type and the response attributes. You can define the response body by adding attributes or by defining attributes in a JSON script.
    1On the operation panel, click Response.
    2In the Headers area, click +.
    3In the Name field, enter a name for the header.
    4From the type list, select a header type.
    5Optionally, in the Description field, enter a description.
    6Optionally, in the Default Value field, enter a value.
    7To add response body attributes, in the Body area, click +.
    8In the Field Name field, enter a name for the attribute. You can't assign objects with the same name in the response body as the objects in the request body.
    9From the Data Type list, select a data type. If you select Array, from the Array Type list, select an array type. If you select Object, you can add as many child objects or fields under it as required.
    10Optionally, in the Description field, enter a description.
    11Optionally, select Required to make the attribute required. By default, the attribute isn't required.
    12Click Add.
    13Add as many attributes to the response body as required. The order of the attributes determines their order in the response body. Move up or move down the attributes as needed. To delete a response header or an attribute, click the Actions menu on the row of the header or attribute and then click Delete.
    14Optionally, to edit a response code, click Edit Responses. Select a response code from the Response Code list, edit the description in the Description field as needed, and click OK.
    The default response code is 200 OK.
    15To define the response attributes in a JSON script, click JSON and add the response body fields as required. You must provide the fields according to the JSON format displayed in the JSON tab.
    16Click Save.

Step 5. Map an Application Integration process to the operation

Map an Application Integration process to the operation on the operation panel. You can create a new process and map it to the operation or map an existing process.
If you map an existing process, the process input fields must match the API request fields, the process output fields must match the API response fields, and the response code of the Application Integration process must match the response code of the API response.
Note: If you choose to generate a new process and use the same name for a request field and response field of a primitive data type, the process gets generated. However, when you edit the process, an error occurs. You must update the field names and generate the process again. If the conflicting field names are of a complex data type, the process does not get generated. You must update the field names and generate the process again. To avoid issues, always use unique names for the request fields and response fields.
    1On the operation panel, click Implementation.
    To generate a new process, perform the following steps:
    1. aSelect Generate new.
    2. bIn the Name field, enter a name for the process.
    3. The name can't exceed 80 characters, start with a number, or contain special characters.
    4. cClick Browse, select a project or folder where the process must be created, and then click Select.
    5. dOptionally, in the Notes field, enter a description of the process.
    6. eClick Generate.
    7. API Center maps the API request to the process input in the Input Mapping area and the API response to the process output in the Output Mapping area.
    To select an existing process, perform the following steps:
    1. aSelect Map existing.
    2. bClick Browse, select the Application Integration process that you want to map, and then click Select. If any input or output mappings are updated after you map the process, click the Refresh button to refresh the process.
    3. API Center maps the API request to the process input in the Input Mapping area and the API response to the process output in the Output Mapping area.
    4. cOptionally, in the Notes field, enter a description of the process.
    2Click Save.

Step 6. Configure operational policies

Configure policies for an API operation on the operation panel. You can configure security, privacy, rate limit, and response caching policies for an operation.
For more information about policies, see API policies.
    1On the operation panel, click Policies.
    2To associate a security policy, in the Authentication tab, select one of the following options:
    3To associate a rate limit policy to an operation while creating or updating a managed API, in the Rate Limit tab, select a rate limit policy from the existing list.
    The values of selected rate limit policy appear. If you leave the field blank, the organization level rate limit policy values are shown and applied.
    4To associate a response caching policy, in the Response Caching tab, select one of the following options:
    5To associate a privacy policy, in the Privacy Settings tab, select one of the following options:
    6Optionally, in the Notes fields, describe the policies.
    7Click Save.

Step 7. Configure a response timeout

Configure a response timeout for an operation on the REST API page. If a response isn't received within the specified time, the request times out. The operation response timeout takes precedence over the organization response timeout.
    1On the operation panel, click Configuration.
    2In the Timeout field, enter a timeout value between 1 and 180 seconds.
    3Click Save.