1

我正在尝试使用 Microsoft REST API 将文件上传到 OneDrive。我正在将访问令牌传递给从 Azure AD 服务获得的请求:

URL urlTest = new URL("https://graph.microsoft.com/v1.0/me/drive/root:/TestFolder/RaviPdf.pdf:/content");
LOGGER.info("url1  : "+urlTest );

HttpURLConnection httpConn = (HttpURLConnection) urlTest.openConnection();
LOGGER.info("conn1  : "+httpConn );
httpConn.setDoOutput(true);
httpConn.setRequestMethod("PUT");
httpConn.setRequestProperty("Authorization", "Bearer " + accessToken);
httpConn.setRequestProperty("Accept","application/json");
httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
httpConn.setRequestProperty("charset","UTF-8");
httpConn.setRequestProperty("Content-Length",Integer.toString(100));

OutputStream os = httpConn.getOutputStream();
os.write(bArray);
os.close();  //don't forget to close the OutputStream
httpConn.connect();
httpResponseCode = httpConn.getResponseCode();
LOGGER.info("httpResponseCode "+httpResponseCode );
//here just printing error stream result 
LOGGER.info("httpConn.getErrorStream())"+httpConn.getErrorStream());

作为回应,我收到此错误:

{
  "error": {
    "code": "notAllowed",
    "message": "You do not have access to create this personal site or you do not have a valid license",
    "innerError": {
      "request-id": "8d09ab84-a922-4713-9643-bbc533af41f9",
      "date": "2019-05-10T11:09:59"
    }
  }
}
4

0 回答 0