Forum Discussion

yagcioe's avatar
yagcioe
Copper Contributor
Feb 01, 2021

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

Hi,
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();
    //console.log(res);
    if (res === undefined || res.id === 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?

Resources