Skip to main content
Announcements
Talend Data Catalog 8.0 End of Support: December 31, 2024 Get Details

How to: Getting started with the API key connector in Qlik Application Automation

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Ankit_KSingh
Support
Support

How to: Getting started with the API key connector in Qlik Application Automation

Last Update:

Mar 23, 2023 12:10:46 AM

Updated By:

Ankit_KSingh

Created date:

Feb 27, 2023 4:04:53 AM

This article is meant to get users starting on the API key connector in Qlik Application Automation.
This connector is designed for advanced users to connect to platforms that do not have a dedicated connector

The connector employs the API key authentication flow, which requires only the API key to make requests to a specific API. 

Index:

 

Limitations

  • This connector will work with the majority of API key flows. In cases where there are additional fields to be sent such as additional query parameters in the authorize request, this connector will not work.
  • APIs that send the result directly in an array is not supported in List Requests. You can use the Raw API request endpoint to run these.
    For example:
    Supported results type :
    {
    
    	"content": [{
    		"endDate": "2021-11-01T05:55:00.000+0000",
    		"status": "unpublished",
    		"created": "2021-06-16T18:40:12.000+0000",
    		"websiteUrl": "https://events.bizzabo.com/337104",
    		"modified": "2021-08-30T20:54:52.000+0000",
    		"timezone": "America/Denver",
    		"name": "Pluralsight LIVE 2021"
    
    	}]
    }

    Not Supported results type : 

    [{
    		"endDate": "2021-04-08T19:00:00.000+0000",
    		"status": "published",
    		"websiteUrl": "https://events.bizzabo.com/309250",
    		"modified": "2021-04-01T16:38:46.000+0000",
    		"timezone": "America/Denver",
    		"name": "Pluralsight Summit",
    		"id": 309250
    }]

 

How to connect

Begin by looking for the "API Key Connector" connector. When you click connect, the following input parameters are requested:

  1. Connector name: A name for the connection. This can be used as an identifier for the user in the editor to differentiate between different API key connections.
  2. Type: Here you can specify how the API key should be included in the request.
    1. HTTP header: If the API key is to be included in the HTTP header. 
      GET / HTTP/1.1  
      Host: example.com  
      Authorization: Basic <api_key>
    2. querystring : If the API key is to be sent as part of the URL as a query string
      curl -X GET "https://example.com/endpoint/?api_key=<api_key>"​
  3.  Authentication name:  Enter the name of the field where the API key is sent here.
                   In the preceding examples, for example, Authorization is an authorization header and api_key is a query parameter.
  4. API Key:  You must enter the API key that will be sent here. (When entering, include the Basic/Bearer prefix.)
                     Basic <api_key>= and <api_key>from the preceding examples.
  5. Base URL: This should be the beginning of the URL to which you will be making REST calls. We recommend                including this as much as possible because it prevents calls to other URLs. (Omit the https://)
                    From the preceding examples, consider example.com.

 

How to use in an automation

When selecting the connector in automation you will notice that there are only a few blocks available, depending on the type of request and pagination involved in your request. These blocks have the following input variables:

  1. RAW API REQUEST BLOCK
    • Path: This needs to be relative to the Base URL you provided when connecting.
    • Method: Enum choice between GET, POST, DELETE, PATCH or PUT. 
    • Query Parameters: Here you can provide a JSON object and the key/values will be added to the path as query parameters.
    • Request Body:  A JSON object can be provided for POST, PATCH or PUT operations that will be sent as a request body.
    • Headers: JSON object and these keys/values will be added as headers to the request.
  2. RAW API LIST REQUEST BLOCK(s)
    • Method: Enum choice between GET, and POST in case of the block with No Paging Support is selected. The rest of the List Request blocks use the GET method by default.
    • Json Path for Output Records: This field is used to parse a section of the JSON returned by the API endpoint. This only returns a parsed VALUE.
    • Other Input Parameters: Other input parameters in the blocks are determined by the type of paging supported by the block. You can find more information about those under the input text boxes.
    • Json Path for Cursor : This field is used to indicate the location of "next page URL" or the "token" for the next page in the response.

 

An Example

The following example will obtain list of events from the Tripletex application. We do not yet have a connector to do this and API key is used to obtain the value for the Authorization header/ Query string.  We first start by obtaining the Base URL and API Key. From the Tripletex documentation we can find these at https://api.tripletex.io/v2-docs/#/ . We use the following values: 

  • Connector Name :  Tripletex
  • Type : httpheader
  • Authentication name : Authorization
  • API Key : Basic {example API key}
  • Base URL : api.tripletex.io/v2/

Once you fill the above details in the connector connection pop-up and click save, it would say the connector is connected. But since this is a generic connector, we don't have a way of verifying if the connector is actually connected. This will be evident when you run an endpoint.  

api_key_1.png

 

Using it in an automation

Create a new automation and drag the Raw API List Request Offset Based Paging block from the API Key connector on to the canvas.  Since the Tripletex connector supports offset based paging, we will be using the Offset Based Paging block to execute the list events api. 

Raw API List Request Offset Based Paging block inputs are as follows:

  • Path : event  ( we have already provided "api.tripletex.io/v2/" during connection, "https://" is added by default)
  • Query Parameters : (No query parameters required for this list events API)
  • Headers : (No extra headers required, "Accept: application/json" is sent by default)
  • Page Size Field Name : count 
  • Page Size : 100
  • Offset Field Name : from
  • Offset Start : 0  
    These last four parameters enable the offset based paging. You can read more about this here.
  • Json Path For Output Records : value ( The results for this list event API are sent inside a "value" array)

    api_key_2.png



    api_key_3.png

      Now when you execute this, it will return you the list of events in Tripletex.

    api_key_4.png

     

The information in this article is provided as-is and is to be used at your own discretion. Depending on the tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.

 

 

 

Labels (2)
Comments
jmcy2408
Contributor III
Contributor III

Great article.

 

I'm able to get a  response using the API Key Connector - Raw API Request block - the API we're using has a default of 30 results per page and this block shows the 30 results.

 

I've tried to setup using the API Key Connector - Raw API List Request Page Number Based Paging but having little success.  If i were to pass page size and page into the URL it would be field names,it would be &pageSize=20&page=2 and via postman this works fine .

 

I've tried passing pageSize and page into the block but i get no results.

Heres how it looks on postman.

For the REST Connector for pagination within an apps data sources i use the header fields Result-Pages, Result-Total for pagination, ive tried those but again no results.

 

Any ideas where i'm going wrong?

Thanks

John

 

Qlik Automations - API Key Connector - Pagination.PNG

jmcy2408
Contributor III
Contributor III

Qlik Automations - API Key Connector - Pagination 2.PNG

jmcy2408
Contributor III
Contributor III

if hell

if helps, the response looks likes this, it comes back in an array, so i use the . for json output - don't know if thats right or not?

Qlik Automations - API Key Connector - Pagination 3.PNG

Jayarams
Support
Support

HI @jmcy2408 ,

If the business data in the API response is not contained in a JSON key, the list blocks will not function.
Only responses like the ones below make it work.

{
 "data":[
  {
   "id":12,
   "cost-center": "",
   "name": "example"
  },
  {...}
 ],
 "page":1,
 "pageSize":20
}


AND period should be used in the "json_path_for_output_records" input parameter to point to the nested array. As in data.companies.quotes if the API response looks like this

{
 "data": {
  "companies": {
   "quotes":
   [
    {
     "id":12,
     "cost-center": "",
     "name": "example"
    },
    {...}
   ]
  }
 },
 "page":1,
 "pageSize":20
}

 

jmcy2408
Contributor III
Contributor III

HI @Jayarams 

 

Thanks for coming back to me.

Doesn't look like the API Key block will work for us at this time then as the page and pageSize is not contained within the response.  

I'll revert to using Call URL, getting the header info containing pages and looping through.

 

Thanks

John

Jayarams
Support
Support

HI @jmcy2408 

It's not about the page or the size of the response. It is instead about how the business data is stored within the Json key, as previously explained. It's also mentioned in the article's Limitation section.  

Unfortunately, the API you are using does not support it.😞

Version history
Last update:
‎2023-03-23 12:10 AM
Updated by: