我正在嘗試向網站發送請求以從中獲取一些數據。但是,響應是垃圾字符,例如:ì 3ú¢?<N¤@H±ü>§#Fe??+K·fDc?±aOqaò;'êù!°a<ro\?YDó?1K`òúüb¨?Tcí?這只發生在有數據的休息時,錯誤也能正常工作。響應應該是這樣的(來自瀏覽器請求): {"d":[{"__type":"CalendarTransport:http:...","activityId":2662,"activityImportIdentifier":null,"activityType":1,"allDay":false,"attendanceMode":1,....這是我的代碼 try { HttpsURLConnection httpsURLConnection; httpsURLConnection = (HttpsURLConnection) new URL("https", redacted, redacted).openConnection(); try { httpsURLConnection.setRequestMethod("POST"); } catch (Exception e) { Log.d(TAG, "doInBackground: oh no (3) it's a " + e.toString()); } httpsURLConnection.setRequestProperty("Accept-Charset", "*/*"); httpsURLConnection.setRequestProperty("Accept-Encoding", "gzip, deflate, br"); httpsURLConnection.setRequestProperty("Connection", "keep-alive"); httpsURLConnection.setRequestProperty("Content-Type", "application/json"); httpsURLConnection.setRequestProperty("Cookie", new DomainCookies(redacted).toRequestHeader()); httpsURLConnection.setDoOutput(true); httpsURLConnection.setDoInput(true); OutputStream os = httpsURLConnection.getOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8"); osw.write(redacted); osw.flush(); osw.close(); os.close(); 瀏覽器可以得到很好的響應,它一定是我正在做的事情(或 android,但我懷疑)
添加回答
舉報
0/150
提交
取消