Мы пытаемся загрузить изображения с точки доступа, используя токен доступа в java.
ниже указаны необходимые данные.
String imgUrl = "https://xxx/SiteCollectionImages/Lists/dicussion%20board/Flat/data-transfer-img.png";
URL imageUrl = new URL(imgUrl);
URLConnection conn = imageUrl.openConnection();
conn.setRequestProperty("Authorization","Bearer eyJ0eXAiOiJKV1QiLeyJ0eXAiOiJKV1QiLeyJ0eXAiOiJKV1QiL");
conn.setDoOutput(true);
conn.connect();InputStream is = conn.getInputStream();
мы передаем токен доступа, но мы получаем ответ об ошибке.
Exception in thread "main" java.lang.RuntimeException: error occured while downloading the attachments : https://xxx/SiteCollectionImages/Lists/dicussion%20board/Flat/data-transfer-img.pngjava.io.IOException: Server returned HTTP response code: 401 for URL: https://xxx/SiteCollectionImages/Lists/dicussion%20board/Flat/data-transfer-img.png
at com.lingotekpatch.controller.SarepointInlineImages.getInputStreamByUrl(SarepointInlineImages.java:62)
at com.lingotekpatch.controller.SarepointInlineImages.main(SarepointInlineImages.java:40)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://xxx/SiteCollectionImages/Lists/dicussion%20board/Flat/data-transfer-img.png
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
at com.lingotekpatch.controller.SarepointInlineImages.getInputStreamByUrl(SarepointInlineImages.java:60)
... 1 more
Может ли кто-нибудь помочь с этим?
Спасибо,
Равиндра.