Загрузка данных из ответа REST API, но получение кода ответа -1 - PullRequest
1 голос
/ 05 февраля 2020

REST API подробности из документации:

GET /REST/sql_snapshot/2003-03-01.sql.gz HTTP/1.1
Host: some.api.net
Authorization: Basic qpow3i12o3

The response shown below omits the message body, which contains binary compressed SQL data.

HTTP/1.1 200 OK
Date: Wed, 05 Mar 2003 10:19:46 GMT
Server: Apache/1.3.22 (Unix)  (Red-Hat/Linux)Content-Type: application/octet-stream

Я получаю код ответа -1 снизу.

URL url = new URL("https://some.api.net/REST/sql_snapshot/2003-03-01.sql.gz");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Content-Type", "application/octet-stream");
connection.setDoOutput(true);
connection.connect();
...