public void createNewVariable(String varId, String description, String title, String location, VariableType varKind) {
String url = makeUserUrl() + "/variable";
_log.info("URL:" + url);
Client http = new Client();
http.addHeader("Authorization", "AuthSub token=\"" + _authToken + "\"");
http.setContentType("application/atom+xml");
String uploadString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
+ " <entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:meter=\"http://schemas.google.com/meter/2008\">" + " <meter:variableId>"
+ varId + "</meter:variableId>" + " <title>" + title + "</title>" + " <content type=\"text\">" + description + "</content>"
+ " <meter:location>" + location + "</meter:location> " + " <meter:type>electricity_consumption</meter:type>"
+ " <meter:unit>kW h</meter:unit>";
if (varKind.name().equals(VariableType.CUMULATIVE.name())) {
uploadString += "<meter:cumulative/>";
} else if (varKind.name().equals(VariableType.DURATIONAL.name())) {
uploadString += "<meter:durational/>";
} else {
throw new IllegalArgumentException("Unknown kind: " + varKind);
}
uploadString += "</entry>";
String res = http.postToString(url, uploadString);
if (http.getResult() < 200 || http.getResult() > 210) {
_log.error("Error POST: code=" + http.getResult() + "\n" + res);
_log.error("POST error");
_log.error("url=" + url);
_log.error("data:\n" + uploadString);
} else {