Ask a question
Fuel your AI at the ultimate IBM learning event
IBM TechXchange Conference October 21-24, 2024 Mandalay Bay - Las Vegas
This recipe would help with a sample code used to invoke REST API from server script with LTPA token.In this example we will be retrieving error details of instances.
var url = “https://yourserver:yourserverport/rest/bpm/wle/v1/process/errors?instanceIds=12345”;var ssoToken = Packages.com.ibm.websphere.security.web.WebSecurityHelper.getSSOCookieFromSSOToken();var httpClient = new Packages.org.apache.commons.httpclient.HttpClient();var method = new Packages.org.apache.commons.httpclient.method.PutMethod(url);method.setRequestHeader(new Packages.org.apache.commons.httpclient.Header(“Cookie”, “LtpaToken2=”+ssoToken.getValue()));var responseCode = String(httpClient.executeMethod(method));var response = method.getResponseBodyAsString();