theNaspenGrove / Backup-Utility

A tool to provide quick and stable backups for servers hosted using the Pterodactyl game panel. It requires another machine to run on and an sshfs mount to work correctly, but the goal is to completely offload the backup process and make it independent of the game server or mod loader you're running.
0 stars 1 forks source link

Basic API implantation in Java #3

Closed n-aspen closed 3 years ago

n-aspen commented 3 years ago

HttpURLConnection http = (HttpURLConnection)url.openConnection();
http.setRequestMethod("POST");
http.setDoOutput(true);
http.setRequestProperty("Content-Type", "application/json");
http.setRequestProperty("Accept", "application/vnd.wisp.v1+json");

http.setRequestProperty("Authorization", "Bearer <KEY>");

String data = "{\"command\": \"<COMMAND>\"}";

byte[] out = data.getBytes(StandardCharsets.UTF_8);

OutputStream stream = http.getOutputStream();
stream.write(out);

System.out.println(http.getResponseCode() + " " + http.getResponseMessage());
http.disconnect();
n-aspen commented 3 years ago

All sorted!