I try to create a ticket from Java. I am not sure what I do wrong, maybe you can help me. I get an HTTP 400 error. Here is my code:
URL url = new URL ("https://support.dbschema.com/api/v1/tickets");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json; utf-8");
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);
String jsonInputString = "{\n" +
" 'title': 'Help me!',\n" +
" 'group': 'Technical',\n" +
" 'customer': 'email_of_existing_customer@example.com',\n" +
" 'article': {\n" +
" 'subject': 'some subject',\n" +
" 'body': 'some message',\n" +
" 'type': 'note',\n" +
" 'internal': false\n" +
" },\n" +
" 'note': 'some note',\n" +
"}";
try( OutputStream os = con.getOutputStream() ) {
byte[] input = jsonInputString.getBytes( StandardCharsets.UTF_8 );
os.write(input, 0, input.length);
}
StringBuilder response = new StringBuilder();
try( BufferedReader br = new BufferedReader( new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8 ))) {
String line;
while ((line = br.readLine()) != null) {
response.append(line.trim());
}
System.out.println(response.toString());
}