I am using Veeva Vault java sdk. We are trying some vault-triggers and successfully we are able to land in our desired java method. From there we need to call external apis. But the problem is that we cannot use any HTTPClient libraries, as veeva vault do not support any external libraries apart from jdk classes (Even veeva doesn’t include jdk network packages). Do anybody know how to use external libraries in Veeva vault?
While in debugger mode, the below code runs, but when we deploy this veeva vault, vault cannot find HttpClient classes. Veeva vault just ask for java files and one xml file which is compressed in .vpk and uploaded in vault.
@RecordTriggerInfo(object = "welotranslate__c", events = {RecordEvent.BEFORE_INSERT})
public class HelloWorld implements RecordTrigger {
public void execute(RecordTriggerContext recordTriggerContext) {
final HttpGet request = new HttpGet("https://www.google.com"); // this class not found
HttpClient httpClient = HttpClients.createDefault(); // this class not found
HttpGet httpGet = new HttpGet("http://www.google.com"); // this class not found
HttpResponse response = null;
try {
response = httpClient.execute(httpGet);
} catch (IOException e) {
throw new RuntimeException(e);
}
String responseString = null;
try {
responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println(responseString);
RecordService recordService = ServiceLocator.locate(RecordService.class);
List<Record> recordList = VaultCollections.newList();
for (RecordChange inputRecord : recordTriggerContext.getRecordChanges()) {
String name = inputRecord.getNew().getValue("demo__c", ValueType.STRING);
inputRecord.setError("amazing", responseString.substring(0,3));
}
}
[type=INVALID_DATA,message=javasdk/src/main/java/com/veeva/vault/custom/triggers/HelloWorld.java:7: error: package org.apache.http does not exist
import org.apache.http.HttpResponse;
^
javasdk/src/main/java/com/veeva/vault/custom/triggers/HelloWorld.java:8: error: package org.apache.http.client does not exist
import org.apache.http.client.HttpClient;
^
Anil Gola is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.