1
私はQuickblox REST APIを使用しています。私がPOSTMANから走ろうとしているとき、それは私に適切な出力を与えています。しかし、私は私のJavaコードを通じてそれを使用しています。これは、エラーの下に私を見せている。auth_keyが必要です:Quickbloxエラー
ここauth_key is required
は私のJavaコードです:
URL url = new URL("https://api.quickblox.com/session.json");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
String current_date = dateFormat.format(cal.getTime());
Date newdt = dateFormat.parse(current_date);
long unixTime = newdt.getTime()/1000;
String nonce = randomString(5);
String message ="application_id=XXXXX&auth_key=XXXXX&nonce=xxxxtimestamp=xxxx";
JSONObject arrayElement = new JSONObject();
arrayElement.put("application_id", "xxxxxx");
arrayElement.put("auth_key", "xxxxxxx");
arrayElement.put("nonce", nonce);
arrayElement.put("timestamp", unixTime);
arrayElement.put("signature", hmacDigest(message, secret, "HmacSHA1"));
conn.setRequestProperty("data", arrayElement.toJSONString());
conn.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
HashMap hmdata = new HashMap();
while ((inputLine = in.readLine()) != null) {
hmdata.put("data", inputLine);
}
in.close();
誰が私はこのエラーを解決するのに役立つことはできますか?
はいを送るどのような形式で理解していないため
が。今働いている。私の問題は、残りのクライアントに入力を送ることでした。だから、私はoutputstreamを使用して、コードは今うまく動作しています。 jsonオブジェクトでデータを送信するために「Accept」から「content-Type」に変更されました –