Мы пытались следовать инструкциям здесь, чтобы установить sh нисходящий поток с помощью запроса GET с этого веб-сайта: https://developer.amazon.com/en-US/docs/alexa/alexa-voice-service/manage-http2-connection.html#Maintaining% 20an% 20HTTP / 2% 20Connection
Here is the code:
/* The user is signed in */
Log.d( "accessToken", "authorizeResult.toString(): " + authorizeResult.toString());
Log.d("accessToken", "accessToken: " + accessToken);
// OkHttpClient: establish a downchannel stream
OkHttpClient httpClient = new OkHttpClient();
OkHttpClient downChannelClient = httpClient.newBuilder() //httpClient Variable? Declare at beginning
.connectTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)//.connectionPool(connectionPool)
.build();
// OKHttp header creation.
final Request request = new Request.Builder()
.url("https://alexa.na.gateway.devices.a2z.com")//endpoint url
.get()
.addHeader("method", "GET")
.addHeader("scheme", "https")
.addHeader("path", "/" + AVS_API_VERSION + "/directives")
.addHeader("authorization", "Bearer " + accessToken)
// A boundary term is required in the header of each event sent to AVS
.addHeader("content-type", "multipart/form-data; boundary=" + BOUNDARY_TERM)
.build();
Log.d("Request_header", request.toString());
Call currentCall = downChannelClient.newCall(request);
Response response = null;
try {
response = currentCall.execute();
}
catch (IOException e) {
Log.d("Response error", e.getMessage());
}
if (response != null && response.body() != null) {
Log.d("Response_success", String.valueOf(response.isSuccessful()));
Log.d("Response_str", response.toString());
}
Но мы продолжаем получать код 404 и ложный ответ.
D/Request_header: Request{method=GET, url=https://alexa.na.gateway.devices.a2z.com/, headers=[method:GET, path:/v20160207/directives, authorization:Bearer <access_token_censored>, content-type:multipart/form-data; boundary=------------------------qM9tn4VZyj]}
D/Response_success: false
D/Response_str: Response{protocol=h2, code=404, message=, url=https://alexa.na.gateway.devices.a2z.com/}
Мы не уверены, правильно ли настроен наш запрос.