Feb 01 2021 09:16 AM - edited Feb 01 2021 09:16 AM
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?
Feb 01 2021 09:42 AM
Solution@yagcioe
NVM got it now:
the request abouve returns an item id and the group id is already know, therfore
PATCH https://graph.microsoft.com/v1.0/groups/{g-id}/drive/items/{item-id}/ListItem/fields
is working.
The body of the request looks like
{
"FieldName":"Value",
...
}