I am trying to send an HTTP POST request using java. I was able to send a simple json message but when I try to add multiple properties to the json message I get a 400 bad request response. I am attempting to use Gson to_json in order to properly display it. Does anyone see where I am going wrong?
public boolean Record(String message, LevelType levelType)
{
    try
    {
        URL url;
        url = new URL(String.format("https://intake.opbeat.com/api/v1/organizations/%s/apps/%s/errors/", this.OrganizationId, this.AppId));
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
        conn.setRequestProperty  ("Authorization", "Bearer " + this.SecretToken);
        conn.setRequestProperty("Content-Type", "application/json");
        conn.setRequestProperty("Accept", "application/json");
        conn.setRequestMethod("POST");
        conn.setDoOutput(true);
        //write parameters
        OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
        JsonObject test = new JsonObject();
        test.addProperty("Application ", ApplicationName);
        test.addProperty("Environment ", environment.name());
        test.addProperty("error ", message);
       String testAsJson = new Gson().toJson(test);
        writer.write(testAsJson);
        writer.flush();
        writer.close();
        // Get the response
        int responseCode = conn.getResponseCode();
        StringBuffer answer = new StringBuffer();
        BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = reader.readLine()) != null)
        {
            answer.append(line);
        }
        reader.close();
        //Output the response
        CustomLog.printlnVerbose(answer.toString());
    }
    catch (MalformedURLException ex)
    {
        CustomLog.println(ex);
    }
    catch (IOException ex)
    {
        CustomLog.println(ex);
    }
    //Send an http post to opbeat
    return true;
}
}
 
    