Skip to Content
Technical Articles
Author's profile photo Cameron Swift

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 value in X-API-TOKEN is a stand-in for your individual Qualtrics API Token)

Sample%20API%20Request

Sample API Request

 

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

Fields%20in%20the%20Connection%20are%20marked%20in%20Green%2C%20Operator%20fields%20marked%20in%20Blue

Fields in the Connection are marked in Green, Operator fields marked in Blue

 

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

Click%20to%20create%20a%20new%20Connection

Click to create a new Connection

 

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’)

 

Creating%20the%20connection%20in%20Connection%20Management

Creating the connection in Connection Management

 

We can retrieve our API Key Value from Qualtrics. We do this by navigating to Account Settings -> Qualtrics IDs ->IDs

 

Demo%20text

Retrieving our Qualtrics API Token

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

OpenAPI%20Client%20operator%20can%20be%20found%20under%20Connectivity

OpenAPI Client operator can be found under Connectivity

 

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

Setting%20the%20Base%20Path%20and%20Connection%20for%20our%20OpenAPI%20Client%20Operator

Setting the Base Path and Connection for our OpenAPI Client Operator

 

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

Our%20finished%20graph

Our finished graph

Save and run your graph, then select the Wiretap operator and click on the Open UI symbol to check the output

Our%20Wiretap%20Output%20shows%20that%20our%20request%20is%20successful

Our Wiretap Output shows that our request is successful

 

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

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Rajesh Kumar Katkoori
      Rajesh Kumar Katkoori

      Hi Cameron,

      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?

      Regards,

      Rajesh

      Author's profile photo Cameron Swift
      Cameron Swift
      Blog Post Author

      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

      I've been meaning to write a more fleshed out blog post covering extra parameters, but I would highly recommend you read the documentation for the OpenAPI Client Operator within the modeler itself. In short, the in port on the Client Operator accepts input of type message. You can use this to pass extra arguments (for example, you can use something like a Javascript(v2) Operator to set your additional parameters, before sending these through an out port to the OpenAPI Client Operator)

      Hope this helps,

      Cameron

      Author's profile photo BIBEK PATRO
      BIBEK PATRO

      HI Cameron,

      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.

      Thanks,

      Bibek Patro