Created
March 16, 2016 07:04
-
-
Save muehlburger/f87e7937ee8a3df39e77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String createAttachment(String caseId, String path, String filename) throws Exception { | |
Path file = Paths.get(path); | |
byte[] data = Files.readAllBytes(file); | |
JSONObject obj = new JSONObject(); | |
obj.put("ParentId", caseId); | |
obj.put("Name", filename); | |
obj.put("body", new String(Base64.encodeBase64(data))); | |
List<JSONObject> response = doPost("Attachment", obj.toString()); | |
String documentId = ""; | |
if(response.size() > 0) { | |
JSONObject result = response.get(0); | |
if(result.getBoolean("success")) { | |
documentId = (String) result.getString("id"); | |
} | |
} | |
return documentId; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment