Create Ticket from Java

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());
        }

Please use the template… it helps to know your system better.

* Used Zammad version: 
* Used Zammad installation source: (source, package, ...)
* Operating system: 
* Browser + version: 


### Expected behavior:

* 


### Actual behavior:

* 


### Steps to reproduce the behavior:

* 

Beside, those kind of issues normally have a error message in the production log. It might help, at least if “400 Bad request” is everything your script returns.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.