Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] tREST and Authentication

How may I authenticate to an endpoint using Basic Authentication with the tREST component?
Labels (3)
2 Replies
Anonymous
Not applicable
Author

Solution:
in a tJavaComponent, go to athe advanced settings and add the following import:

import com.sun.jersey.core.util.Base64;

In the basic settings, add the following code:
String pair = "<username>:<password>";
byte[] encodedBytes = Base64.encode(pair.getBytes());
globalMap.put("authorization", new String(encodedBytes));
System.out.println(globalMap.get("authorization"));

Now connect the tJava to the tRest using the OnComponentOk trigger.
In the tRest, add a HTTP Header called "Authorzation" and set it to "Basic " + (String)globalMap.get("authorization"):
0683p000009MAr4.png
jasbir_purewal
Contributor
Contributor

How can I also add the Domain to the request??