In order to use these APIs, you have to provide authentication details with the request in request header.
First join the username and the password with a colon and encode it using Base64 encoder. Then append the word "Basic " (note the space) and put as "Autorization" header.
Ex:-
"Basic " + Base64Encode(<username> + ":" + <password>)
See below working complete code written in java to get the task list of krisv.
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
public class JBPMRest {
public static void getTaskSummaryList() throws Exception {
String status = "Reserved";
String actor = "krisv";
String addr = "http://localhost:8080/jbpm-console/rest/task/query?status=" + status + "&potentialOwner=" + actor;
try {
HttpClient client = HttpClientBuilder.create().build();
HttpGet get = new HttpGet(addr);
String authData = "krisv" + ":" + "krisv";
String encoded = new sun.misc.BASE64Encoder().encode(authData.getBytes());
get.setHeader("Authorization", "Basic " + encoded);
get.setHeader("Content-Type", "application/json");
get.setHeader("ACCEPT", "application/xml");
HttpResponse cgResponse = client.execute(get);
String content = EntityUtils.toString(cgResponse.getEntity());
System.out.println(content);
} catch (Exception e) {
throw new Exception("Error consuming service.", e);
}
}
}
Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
ReplyDeletepython course institute in bangalore
python Course in bangalore
python training institute in bangalore
Thanks Admin for sharing such a useful post, I hope it’s useful to many individuals for developing their skill to get good career.
ReplyDeleteData Science Training in Indira nagar
Data Science Training in btm layout
Python Training in Kalyan nagar
Data Science training in Indira nagar
Data Science Training in Marathahalli
Boost your career with our comprehensive salesforce admin training
ReplyDeletedesigned for beginners and professionals to master Salesforce administration. Learn real-world skills, earn certification, and manage Salesforce like a pro.
Boost your career with comprehensive salesforce developer training
ReplyDeletemastering Apex, Visualforce, and Lightning components for real-world applications. Gain hands-on experience and industry-recognized skills to become a proficient Salesforce developer.
Fantastic article! Our data modeling courses online
ReplyDeleteequip professionals with the skills to design robust, high-performance databases.
Well-written! Learn normalization, best data modelling courses
ReplyDeletedata mapping, and physical modeling with our hands-on, career-focused training.