This article shows how to use and create custom rest connector in webMethods.io Integration.
When you are integarting with a Rest application with multiple resources, instead of using http invokes/calls in your workflow or FlowService, its better to create a rest connector and use it. Which will help you to define common Error response/handling, common Authentication handling, sharable/reusable structures/document types etc.
As an example we will use the open petstore swagger https://petstore.swagger.io/ as our rest application to showcase this usecase.
- Creating custom rest connector
- Creating reources
- Creating account
- Creating operations
- Create / Open your project in IO tenant
- Navigate to Connectors > Rest and click on Add Connector. provide name, URL(https://petstore.swagger.io/) and select Credentials as Authentication Type and save
- Click Add Resource with name (example:findPetsByStatus) and path as shown below
- Click and select the respective method (GET).
- Add Parameters status as , Header Content-Type and Accept with value application/json
-
Add request body if needed.
-
Add response body for HTTP range 200-299, to create a document type you could execute the resource in postman and copy the result json.
- Add another response body for HTTP range 400-599 for Error. Even for Error you could create a common document type. Also please sure to select "Error Response".
- Navigate to Connectors, Hover over the created connector and click on Add Account. Select Authorization Type as Basic (just example) and rest could be left default.
- Navigate to Connectors, hover over the created connector and click Operations
- Click Add Operation, provide a name (example: findBytStatus), select the created account and save it.
You could find the export of Workflow using, along with Connector definitions in assets/workflow.
- Login to wM.IO tenant
- Navigate to project where you want to import
- Import the zip from assets/workflow
- Add an account with name "Oauth_None" and details as provided in markdown