Solved
PostJSON in ThingWorx 9.0 Extension SDK
- October 15, 2020
- 1 reply
- 2888 views
Has anybody been successful using the ContentLoader functions in TWx 9.0 Extension SDK? I've been following this example and this javadoc but I keep getting a null pointer exception. Just to test my sanity, I used the same url, header, and content information inside a Composer service and I was successful. I've attached the stack trace and the code I'm using is:
public Boolean myService() throws Exception {
Boolean verify = false;
ContentLoader verifyCheck = new ContentLoader();
String url = "https://postman-echo.com/post";
JSONObject content = new JSONObject("{\"meta\":{\"key\": \"" + "abc" + "\"}}");
String username = null;
String password = null;
JSONObject headers = null;
Boolean ignoreSSLErrors = null;
Boolean withCookies = null;
Double timeout = null;
Boolean useNTLM = null;
String workstation = null;
String domain = null;
Boolean useProxy = null;
String proxyHost = null;
Integer proxyPort = null;
String proxyScheme = null;
try {
_logger.warn("URL in myService(): " + url.toString());
_logger.warn("Content in myService(): " + content.toString());
verifyCheck.PostJSON(url, content, username, password, headers,
ignoreSSLErrors, withCookies, timeout, useNTLM, workstation, domain, useProxy,
proxyHost, proxyPort, proxyScheme);
}
catch(Exception e)
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
_logger.error("Exception in myService(): " + sw.toString());
}
return verify;
}
