Laden Sie eine Datei mithilfe von GraphServiceClient hochJava

Java-Forum
Anonymous
 Laden Sie eine Datei mithilfe von GraphServiceClient hoch

Post by Anonymous »

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>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post