Ich versuche Java zu verwenden, um eine Datei auf SharePoint hochzuladen. Wie kann ich das tun?DriveItem driveItem = new DriveItem();
driveItem.setName("New File.txt");
HashMap additionalData = new HashMap();
additionalData.put("@microsoft.graph.conflictBehavior", "rename");
driveItem.setAdditionalData(additionalData);
DriveItem result = graphClient
.drives()
.byDriveId("{drive-id}")
.items()
.byDriveItemId("parentFolder")
.children()
.post(driveItem);
< /code>
Inhalt hinzufügen, < /p>
File testFile = new File(path);
InputStream testStream = new FileInputStream(testFile);
graphClient
.drives()
.byDriveId("{drive-id}")
.items()
.byDriveItemId("uploadedFileId")
.content()
.buildRequest()
.put(fileContentsInBytes, createCallback);
< /code>
und Checkin: < /p>
CheckinPostRequestBody checkinPostRequestBody = new CheckinPostRequestBody();
graphClient
.drives()
.byDriveId("{drive-id}")
.items()
.byDriveItemId("uploadedFileId")
.checkin()
.post(checkinPostRequestBody);
< /code>
Aber das funktioniert nicht. Ich erhalte 502 generisches Serverfehler.
Was mache ich falsch? < /P>
Laden Sie eine Datei mithilfe von GraphServiceClient hoch ⇐ Java
-
- Similar Topics
- Replies
- Views
- Last post
-
-
So erhalten Sie ein Microsoft GraphServiceClient in Java mit einem Zugriffstoken
by Anonymous » » in Java - 0 Replies
- 6 Views
-
Last post by Anonymous
-