Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
When certain documents update, I need to send the primary content via an HTTP POST request. I am having trouble finding any supporting documentation and was wondering if it was possible. If so, how.
Thank you in advance
Solved! Go to Solution.
Hi @VanVelZ
It is simple. Just write primary content to http as a outputstream.
example uses a xml file
URL urlObj = new URL("http://adressToApplication");
HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();
con.setSSLSocketFactory(sslsocketfactory);// it is up to you what security you use
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
con.setRequestProperty("Accept", "text/xml");
con.setRequestProperty("Content-Length", String.valueOf(xmlContent.length()));
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.write(xmlContent.getBytes(StandardCharsets.UTF_8));
wr.flush();
wr.close();
PetrH
Hi @VanVelZ
It is simple. Just write primary content to http as a outputstream.
example uses a xml file
URL urlObj = new URL("http://adressToApplication");
HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();
con.setSSLSocketFactory(sslsocketfactory);// it is up to you what security you use
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
con.setRequestProperty("Accept", "text/xml");
con.setRequestProperty("Content-Length", String.valueOf(xmlContent.length()));
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.write(xmlContent.getBytes(StandardCharsets.UTF_8));
wr.flush();
wr.close();
PetrH
Thank you very much. For clarity, how would I surface the primary content from a WTObject?
Hi @VanVelZ
ContentHelper can help you 😄
WTDocument document = Util.GetDocument("ABCD"); // my own function to get WTDocument - you can use what object you need
ApplicationData syAppData = (ApplicationData) ContentHelper.service.getPrimaryContent(ObjectReference.newObjectReference(document));
InputStream is = ContentServerHelper.service.findContentStream(syAppData ); // InputStream needs to be converted to OutputStream for HTTP OutputStream.
PetrH