Update Group SharePoint Custom Field Collums after Fileupload with REST Graph API in Javascript

Copper Contributor

I've made an upload with Graph with the following JS code:




async function uploadSingleFileMetaToSharepoint(file, name, metaData, groupId, graphAccessToken) {
    //console.log(file, name, metaData, groupId);
    //TODO get Filepath from config of App
    let pathToFiles = 'General'
    let apiurl = msgraph + `/groups/${groupId}/drive/root:/${pathToFiles}/${name}:/content`;
    if (debug) {
        console.log("uploading File: ", file);
        console.log(`API-URL: ${apiurl}`);
    let header = {
        'Authorization': graphAccessToken,
    let body = file;
    //TODO catch errors
    let result = await fetch(apiurl, {
        "method": 'PUT',
        "headers": header,
        "body": body
    if (!result.ok) { console.error("upload file to sharepoint failed"); return }
    let res = await result.json();
    if (res === undefined || === undefined) {console.error("Die DAtei wurde nicht hochgeladen"); return;}





 which is working fine.
But now i'm struggling to fill the values of the collumns from sharepoint :


Does anybody know how to approach this?

1 Reply
best response confirmed by yagcioe (Copper Contributor)

NVM got it now:

the request abouve returns an item id and the group id is already know, therfore 
is working.

The body of the request looks like