Let's create a sample REST API using OIC with below steps
Step1: Create REST connection
Step2: Create Integration by using REST connection
Step3: Configure parameters if any and response as well
Step4: Map the elements for response if required and validate
Step5: Activate the Integration and test
We need a REST connection to create REST API using OIC.
Navigate to Design --> Connections.
Create the connection using create button.
Select REST from the list of the adapters exists
Provide the Integration Name and Integration Identifier, click on create to proceed to next steps.
Select the security policy as Basic Authentication.
Test the connection.
Go to Integrations.
Click on create button to create the integration.
Select Application to create REST API
Provide the Integration Name and Integration Identifier and click on Create button.
Select the REST connection that we created earlier and give the endpoint name and description.
Click and continue button and configure the REST trigger by providing the end point URI (/{name}) so that we can pass name as part of URL and consume it and select the "
Configure this endpoint to receive the response" to send the response upon calling REST API.Click on Continue button and no need to configure the trigger parameters in this screen.
Click on continue and click on inline to add the sample JSON format for response.
Open the mapper in Edit mode and create a target node for message element in response wrapper.
Enable the developer view.
Add the below concat function and drag and drop the name from the left pane.
concat("Hi ",/nstrgmpr:execute/nstrgmpr:TemplateParameters/ns14:name,", How are you?")
Go back to the integration after validating the mapper.
Go to the business identifiers.
Drag and drop the name as business identifier and save the integration.
Go back to all integrations after saving the integration to active the integration.
Enable the debug option to verify the logs and click on activate.
Refresh to check the status of the integration.
Run the integration to test REST API.
Pass the value in name and run.
Observe the response of the API.
To test the API in other tools, click on the Endpoint metadata to get the REST API URL.