Enter a name for the REST API. The name that you specify is used as the name of the project in the IBM Integration Toolkit.
To finish creating the REST API, click Finish. The REST API Editor for the new REST API opens automatically.
To define resources, models, and operations in a REST API, complete the following steps:
1. Header Section
Use the Header section of the REST API Editor to display and modify general information about the REST API.
2. Resources Section
Use this button to create a new resource in the REST API. Select the operations to add.
After clicking OK, the follwowing is displayed.
Use the Add button REST API add parameter and the Delete button REST API delete parameter to add or delete Header and Query parameters, and then set their Name, Type, and Data Type, and optionally, the Format, Required, and Description values.
3. Model Definitions
Use the Model Definitions section of the editor to define the JSON data that you can use for the Request and Response Schema type in the postBusinessPartner operation.
To create a new Model data type, click the Add button next to the Model Definitions field, and enter a name for your new JSON data type:
Click on <Enter q unique name to create a new model > and enter.
3. Model Definitions
Use the Model Definitions section of the editor to define the JSON data that you can use for the Request and Response Schema type in the postBusinessPartner operation.
To create a new Model data type, click the Add button next to the Model Definitions field, and enter a name for your new JSON data type:
Click on <Enter q unique name to create a new model > and enter.
To create an object Model when you have entered its name, use the Add a child for selection button REST API add parameter, located in the top right of the Model Definitions section, to add the first child. You can then add additional children to build up the required structure.
(Image taken from IBM Knowledge Centre)
4. Implementing an operation in a REST API
Operations in a REST API are implemented as a subflow.
To create a subflow for postBusinessPartner operation click.
The subflow for the operation is created and is automatically wired in the main flow.
In the subflow add a mapping node.
Select 'Simple message map called by a message flow node' and click Next.
Implementing an error handler in a REST API
I implemented a Catch Handler to catch all errors that may occur.
A new subflow is automatically created and opened. Implement the error handler by adding any of the standard message flow nodes that are available in IBM Integration Bus to the subflow.
Permitting web browsers to access a REST API by using Cross-Origin Resource Sharing(CORS)
To permit web pages that are running in a web browser to make requests to a REST API that is running in IBM® Integration Bus Cross-Origin Resource Sharing (CORS) needs to be enabled.
To enable CORS on the integration server HTTP listener run the following command.
mqsichangeproperties integrationNodeName -e integrationServerName -o connectorName -n corsEnabled -v true
e.g mqsichangeproperties IBNODE -e default -o HTTPConnector -n corsEnabled -v true
To enable CORS on theintegration node HTTP listener run the following command.
mqsichangeproperties integrationNodeName -b httplistener -o connectorName -n corsEnabled -v true
e.g. mqsichangeproperties IBNODE -o HTTPConnector -n corsEnabled -v true
Hello, Could you please share the steps for adding the catch error handler also in the flow.
ReplyDeleteSorry for the late reply, Nidhi
DeletePlease take a look at this IBM Knowledge Centre article
https://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/bi12028_.html
How can I add http header parameters in the request like content type,authentication....?
ReplyDelete