So this turned out harder than I imagined it to be but eventually with the combination of many forum posts I was able to get it to work.
Basically Base64 encode your username password for use in Basic authentication. Prepend “Basic ” (don’t forget the space) as the Authorization
I was passing Content-Type “application/x-www-form-urlencoded” and for that it means you need to use the format like this something=something&anotherthing=123 (helpful post)
I also randomly learned that postman can generate code! How cool is that!
The post that was the most useful was
https://community.talend.com/s/feed/0D53p00007vCsxdCAC?language=en_US
It has a couple of typos that can throw you though!
First, create a tJava object. Go to the advanced settings and add the following import:
import com.sun.jersey.core.util.Base64; In the basic settings, add the following code: String pair = "yourusername:yourpassword"; 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 “Authorization” and set it to “Basic ” + (String)globalMap.get(“authorization”):
In the original article there are some typo’s so here is a working screen shot
