i am using java process builder to execute the curl command to publish the schema to schema registry but getting error. problem with schema format, not sure how to pass as argument for process builder. please provide any suggestions
enter code here
sourceSchema = "{"additionalProperties":false,"properties":{"age":{"type":"integer"},"firstname":{"type":"string"},"lastname":{"type":"string","minLength":2,"maxLength":4},"email":{"type":"string","format":"email"},"designation":{"default":"","type":"string"},"mobile":{"type":"string","pattern":"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$"}},"required":["firstname","lastname","age"],"title":"customer","type":"object"}";
String convertSourceSchema = sourceSchema.replace("\"", "\\\"");
String constructSourceSchema = "{\"schema\":\""+convertSourceSchema+"\",\"schemaType\":\"JSON\"}";
String[] command = {"curl", "-k", "-X", "POST", "-H", "Content-Type: application/vnd.schemaregistry.v1+json", "--data", ""+constructSourceSchema+"", ""+url+""};
ProcessBuilder process = new ProcessBuilder(command);
Process p;
try
{
process.redirectErrorStream(true);
p = process.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuilder builder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
builder.append(line);
//builder.append(",");
}
String result = builder.toString();
System.out.print(result);
}
catch (Exception e)
{ System.out.print("error");
e.printStackTrace();
}
> Blockquote
error am getting
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 635 100 208 100 427 208 427 0:00:01 --:--:-- 0:00:01 2396Unexpected character ('s' (code 115)): was expecting double-quote to start field name at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 3]2021-02-24 11:19:16.409 INFO 18428 --- [nio-8080-exec-1] c.c.e.s.u.c.SchemaPublisherUtility