I am trying to register my table columns via java code, but I always get an internal server error 500 result with error message "Oops, an error occured". I am logging the json string I am sending to the registerV1 api and if I copy that string from the log and paste it into a file and send using curl, it works fine. If I then try again with my code, I get the error that the table exists, so I know that the register module is getting to the point of parsing my json. I am sending the json as a stream entity. This code works fine when I send data using the postdataV1 api.
Code looks like so:
logger.info("post data to: " + registerUrl);
HttpPost httpPost = new HttpPost(registerUrl);
httpPost.setHeader("Content-Type", "application/json");
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getCredentialsProvider().setCredentials( new AuthScope(mServer, 9000),
new UsernamePasswordCredentials("robot-robotTest2", "45580RCV5S.ALPHA1.1PT80JZFNKHUG"));
String androidID = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID);
String tableJson = "{"datasetType":"RELATIONAL_TABLE", "modelName":"ANDROID4_" + androidID + "", "schema":"sensorTest", " + tableCols + "}";
try {
httpPost.setEntity(new StringEntity(tableJson));
} catch (UnsupportedEncodingException e1) {
logger.severe("encoding error in json string");
e1.printStackTrace();
return;
}
try {
// do the post
logger.info("sending table data: " + tableJson);
HttpResponse response = httpClient.execute(httpPost);
StatusLine status = response.getStatusLine();
logger.info("http post response: " + status.getStatusCode() + " - " + status.getReasonPhrase());
log looks like this:
10-17 11:11:38.638: I/TableProvisioner(3089): post data to: http://15.185.92.96:9000/api/registerV1
10-17 11:11:38.658: I/TableProvisioner(3089): sending table data: {"datasetType":"RELATIONAL_TABLE", "modelName":"ANDROID4_910e2872a4e96f5e", "schema":"sensorTest", "columns":[{"name":"time","dataType":"BigInteger","isIndex":true,"isPrimaryKey":true},{"name":"ROTX","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false},{"name":"ROTY","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false},{"name":"ROTZ","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false}]}
10-17 11:11:38.848: I/TableProvisioner(3089): http post response: 500 - Internal Server Error
10-17 11:11:38.848: E/TableProvisioner(3089): http post error: 500 -
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089): <title>Application error</title>
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
Oops, an error occured
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089): This exception has been logged with id 6fo4f81f7.
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
Copy/paste the table data from the log into a file and sending vial curl looks like this:
kbrems@ubuntu:~/sensorTest$ curl -X POST -w "\nRESULT CODE:%{http_code}\n" --header "Content-Type:application/json" --user robot-robotTest2:45580RCV5S.ALPHA1.1PT80JZFNKHUG -d @dbTable4.txt http://15.185.92.96:9000/api/registerV1
{"modelName":"ANDROID4_910e2872a4e96f5e","groups":[]}
RESULT CODE:200
kbrems@ubuntu:~/sensorTest$ cat dbTable4.txt
{"datasetType":"RELATIONAL_TABLE", "modelName":"ANDROID4_910e2872a4e96f5e", "schema":"sensorTest", "columns":[{"name":"time","dataType":"BigInteger","isIndex":true,"isPrimaryKey":true},{"name":"ROTX","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false},{"name":"ROTY","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false},{"name":"ROTZ","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false}]}
I am trying to register my table columns via java code, but I always get an internal server error 500 result with error message "Oops, an error occured". I am logging the json string I am sending to the registerV1 api and if I copy that string from the log and paste it into a file and send using curl, it works fine. If I then try again with my code, I get the error that the table exists, so I know that the register module is getting to the point of parsing my json. I am sending the json as a stream entity. This code works fine when I send data using the postdataV1 api.
Code looks like so:
logger.info("post data to: " + registerUrl);
HttpPost httpPost = new HttpPost(registerUrl);
httpPost.setHeader("Content-Type", "application/json");
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getCredentialsProvider().setCredentials( new AuthScope(mServer, 9000),
new UsernamePasswordCredentials("robot-robotTest2", "45580RCV5S.ALPHA1.1PT80JZFNKHUG"));
String androidID = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID);
String tableJson = "{"datasetType":"RELATIONAL_TABLE", "modelName":"ANDROID4_" + androidID + "", "schema":"sensorTest", " + tableCols + "}";
try {
httpPost.setEntity(new StringEntity(tableJson));
} catch (UnsupportedEncodingException e1) {
logger.severe("encoding error in json string");
e1.printStackTrace();
return;
}
try {
// do the post
logger.info("sending table data: " + tableJson);
HttpResponse response = httpClient.execute(httpPost);
StatusLine status = response.getStatusLine();
logger.info("http post response: " + status.getStatusCode() + " - " + status.getReasonPhrase());
log looks like this:
10-17 11:11:38.638: I/TableProvisioner(3089): post data to: http://15.185.92.96:9000/api/registerV1
10-17 11:11:38.658: I/TableProvisioner(3089): sending table data: {"datasetType":"RELATIONAL_TABLE", "modelName":"ANDROID4_910e2872a4e96f5e", "schema":"sensorTest", "columns":[{"name":"time","dataType":"BigInteger","isIndex":true,"isPrimaryKey":true},{"name":"ROTX","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false},{"name":"ROTY","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false},{"name":"ROTZ","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false}]}
10-17 11:11:38.848: I/TableProvisioner(3089): http post response: 500 - Internal Server Error
10-17 11:11:38.848: E/TableProvisioner(3089): http post error: 500 -
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089): <title>Application error</title>
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
Oops, an error occured
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089): This exception has been logged with id 6fo4f81f7.
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
10-17 11:11:38.848: E/TableProvisioner(3089):
Copy/paste the table data from the log into a file and sending vial curl looks like this:
kbrems@ubuntu:~/sensorTest$ curl -X POST -w "\nRESULT CODE:%{http_code}\n" --header "Content-Type:application/json" --user robot-robotTest2:45580RCV5S.ALPHA1.1PT80JZFNKHUG -d @dbTable4.txt http://15.185.92.96:9000/api/registerV1
{"modelName":"ANDROID4_910e2872a4e96f5e","groups":[]}
RESULT CODE:200
kbrems@ubuntu:~/sensorTest$ cat dbTable4.txt
{"datasetType":"RELATIONAL_TABLE", "modelName":"ANDROID4_910e2872a4e96f5e", "schema":"sensorTest", "columns":[{"name":"time","dataType":"BigInteger","isIndex":true,"isPrimaryKey":true},{"name":"ROTX","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false},{"name":"ROTY","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false},{"name":"ROTZ","dataType":"BigDecimal","isIndex":false,"isPrimaryKey":false}]}