Skip to Content
Product Information

Build Custom Connector from your Postman Collection using SAP Cloud Platform Integration Suite

Connector Builder functionality of Open Connectors from SAP Cloud Platform Integration Suite enables you to build your own connector for your APIs. Many of you might have already used Postman collection to group your individual API requests to tryout or test against an API using Postman. With the latest innovation in Connector Builder you can now build a custom connector by simply importing your existing Postman collections.

Yelp provides API to get information about the local businesses and their user reviews across many countries.  In this blog, learn to build a custom connector for Yelp Fusion API by importing their Postman Collection available here ( Run in Postman section).

Prerequisites

API Key for Yelp Fusion API access

Yelp Fusion API uses an API Key based authentication which is automatically generated when you create an application in Yelp Developer Portal. Details available here.

Note:- In case, you would like to leverage your own Postman Collection then this step can be skipped.

Build your Yelp Connector using Connector Builder in Open Connector

In this section steps to create a Yelp connector in Open Connector from the Postman collection downloaded from Yelp Developer portal is covered.

  • Logon to your Open Connectors tenant. Open Connectors is also available in SAP Cloud Platform trial for more information refer this blog. In the Cloud Foundry environment, Open Connectors will be available under Subscription and in Neo environment it will be available under Services. Select Open Connector tile and click on Go to Service or Go to Application link.
  • Click on Connectors tab to view all the available pre-built, feature rich connectors. Select Build New Connector to create the custom connector.

  • Select Import to create a custom connector from Postman collection.

  • Select Postman 2.1 from the import option. Select From Computer to upload the postman collection downloaded and saved locally from Yelp.  Next select Continue Import to proceed.

  • Based on your imported Postman collection the available resources would be auto generated. You can select the resources that you would like to use to generate the connector. Check the Select All Resources check box to select all the resources and select Import to generate the connector.

 

  • This will generate the connector based on the imported Postman collection.

  • As the next step, the required authentication to connect to Yelp Fusion API would have to be defined in the generated connector.  Yelp Fusion API uses an API key based authentication, where in the Yelp API Key would have to be passed in the authorization header in the format Bearer {apikey}. Details about Yelp API authentication can be found in here ( under section Authenticate calls with API Key).
  • Add a new configuration to take API key as an input parameter while creating the Yelp connector instance.  Select blank from Add Configuration drop down to add a new configuration for API Key.

  • In the newly added row, Enter apikey as Name, select password from the Type field, Enter Yelp API Key as Description, Select Required option to true.  This will enforce the user to mandatory enter API key as an input parameter while creating the Yelp connector.

 

  • The API Key needs to be passed in all the outgoing request to Yelp API. You can use the PreRequest Hook option to add in the custom logic using JavaScript to be invoked before making any call to the target API from the connector. Select PreRequest Hook to add in the custom logic.

  • Enter the following snippet in the PreRequest Hook code editor and click Save to persist all changes.
let vendorHeaders = request_vendor_headers;

vendorHeaders["authorization"] = "Bearer " +  configuration["apikey"];

done({
	'request_vendor_headers': vendorHeaders
});

In the above snippet,  the apikey is read from the configuration map and then added to the request_vendor_headers map in the format as required by Yelp API.  More details about the PreRequest Hook is available in help documentation.

 

  • You can optionally enter additional information like your connector logo, description by navigating to the Information tab. Select Save & Next to persist the changes.

  • Connector Builder also generates an API documentation from the imported Postman collection. Select API Docs to view the generated API Docs in Open API specification format.

 

With this you have successfully generated a custom connector for Yelp from the Postman collection and also handled the unique authentication approach required by Yelp to invoke their APIs.

Finally Testing of Newly Created Connector

  • Select Authentication instance to create an authenticated connector instance.

 

  • Enter a Name for your connector instance, say yelpdemo and Enter your Yelp key . Select Create Instance to create an authenticated connector instance.

Steps to get your Yelp API Key is available here.

  • After the connector instance is created successfully, select Test in the API docs to test the connections.

  • This would launch the integrated OpenAPI specification based API Documentation for the Yelp connector so that you can test and try out the connectors from Open Connectors.
  • Select any of the available Resources say /businesses/search and click on Try it Out to test the connectivity to third-party applications, enter the parameters like term, latitude, longitude and then click on the Execute Button. For the testing the sample values provided in the API documentation can be used.

 

  • This would show the CURL command with the harmonized RESTFul URIs to your Yelp connector and the normalized authentication token which can be used to securely and seamless connect to Yelp connector.

 

To know more about Open Connectors visit us at SAP Community

1 Comment
You must be Logged on to comment or reply to a post.