SAP Data Intelligence Cloud – OpenAPI Client Basics
This blog post is written in collaboration with the SAP HANA Database & Analytics, Cross Product Management team – thanks to my colleague Wei Han for her help in reviewing this post
Using the SAP Data Intelligence Modeler, we can create pipelines (graphs) to work with data from a number of sources. One of the first things you may want to try when creating your first pipeline is retrieving data via an API
In this brief blog post, we’ll cover the basics of using the OpenAPI Client operator to retrieve data from a Qualtrics API – List Surveys. Once you understand the basics of working with the OpenAPI Client operator, you should be equipped to retrieve data from other API sources
Our API Request
By default, the Qualtrics API Reference presents a sample API Request for Shell/cURL (the x value in X-API-TOKEN is a stand-in for your individual Qualtrics API Token)
At time of writing, the OpenAPI Client operator uses the OpenAPI 2.0 specification (formerly known as Swagger 2.0 specification). In this blog post, we will demonstrate how to map our Qualtrics API Request to this specification, however any further exploration of the OpenAPI specification is considered out of scope
Next we will map the Sample API request to the fields of our OpenAPI Connection and Client operator. A visual breakdown is included below
Creating our Connection
Creating the DI Connection for Qualtrics allows for centralized management of the connection if, for example you rely on more than one API which uses the same connection details
From the Data Intelligence Launchpad, select Connection Management then click on the Create Connection button
For the Connection Type, we want to choose OpenAPI
Host is used to specify the host (name or IP) serving the API. This does not include the scheme or sub-path, but may include the port. For this example, our host is ca1.qualtrics.com
Protocol (Scheme) specifies the transfer protocol of the API. In our case, the protocol used is https
Select ApiKey as our Authentication Type, and fill out the values for API Key Name (this API expects ‘X-API-TOKEN’) and API Key Type (this can be either ‘Header’ or ‘Query’. As we can see from our sample request, the API Key should be sent in the ‘Header’)
We can retrieve our API Key Value from Qualtrics. We do this by navigating to Account Settings -> Qualtrics IDs ->IDs
The value in API Token is the final value we need for our DI Connection. We copy it to API Key Value field, click Create and return to the Modeler.
Creating our Pipeline
First, we start by placing an OpenAPI Client operator on a new graph
First, we will select the OpenAPI Client operator. In our case, the values required for Method and Produces are correct by default – we are making a GET request, and the result is expected in the application/json format. Neither of these values need to be changed
Base Path specifies the base path where the API is served, which is relative to the host. It must begin with a leading slash (/). We want to enter /API/v3/surveys. We then want to select the Connection we just created
Completing our Graph
At this point, all of the necessary configuration of the OpenAPI Client operator has been completed. The operator will make a request when it receives input to its input port. Without the Workflow Trigger operator (or another compatible operator), the openAPI Client will not run
In order for our example to trigger the API Call exactly once, we will place a Workflow Trigger operator into the graph, and connect its output port to the input port of our OpenAPI Client operator
In order to read the API response, we connect the output port of our OpenAPI Client operator to a Wiretap operator. Our graph is now ready to be tested
Save and run your graph, then select the Wiretap operator and click on the Open UI symbol to check the output
In this blog post, we’ve covered how we can use an OpenAPI Client operator to make an API request, and verify the response data in a Wiretap operator. We can store these results in a table in HANA, and use them in combination with other APIs (for example, retrieving responses for individual surveys) for modeling or analytics
This blog post may naturally lead to follow up questions, such as “What if I need to pass in additional parameters”, or “What if I want to dynamically change the values of parameters?”. I hope to cover these questions in future blog posts
I hope this blog post has been useful, and I welcome any comments or questions below
Edited March 2022 – Updated the blog post to reflect the removal of the OpenAPI Client’s manual connection mode
with reference to this block, we have created a RestAPI in SAP ECC system and we are trying to post Data from SAP DI by using this Operator. But I cannot figure it out how to pass Body for GET/POST to call the RestAPI in SAP ECC system. Could you please help how we can pass the Rest API Url and Body to this Open API Client Operator to make a call to ECC?
Thanks for your question Rajesh
I believe the OpenAPI Client Operator may have undergone some changes since I wrote this - I would recommend you create the OpenAPI Connection instead of configuring the details within the OpenAPI Client Operator itself (follow the instructions under the "Creating our API Connection" heading) Edit March 2022: The blog is now up to date with these changes
Hope this helps,
Thanks for providing valuable information here.
I need a guidance in one use case i am working on. I am using OpenAPI Client operator with OpenAPI connection with Authorization method as OAuth2. I am getting error when I am trying to post a message to start a job at server.
Error Message: no route matched with those values.
So here I am not sure whether I am able to reach to server or not. Also how the access token is being handled in this operator since I dont see any placeholder for the access token that we have received from Authorization end point.
Apologies for the delay - I'm assuming you will have figured this out but am replying for others who may read this. When this Blog Post was first written, you could configure the OpenAPI Client Operator in Manual or Connection Modes
Now you must set up the Connection within the Connection Manager to use the OpenAPI Client Operator - the Manual mode is no longer available. Within the Connection Manager itself, you can use the Authentication Type to select OAuth2 and enter the details there
Sending Parameters to OpenAPI Client
I aim to write a follow up to this Blog Post explaining the process when I get the chance. In the meantime, you can check out a worked example in this blog by my colleague: Using SAP Data Intelligence to send Reporting Data from SAP Ariba to SAP Analytics Cloud
Thanks for reading,
Thanks Cameron, BTW SAP has upgraded this operator and now it is working fine.