I'm trying to access the sharepoint Excel charts I have used the following query in Microsoft graph explorer
https://graph.microsoft.com/v1.0/sites/yyyyyy.com/drives/folderiddd/items/id2222/workbook/worksheets('Sheet1')/charts('Chart 2')/Image(width=300,height=300,fittingMode='fit')
This is giving the result.
From the inspect element , network tab I got the Authorization
and I made the Jquery ajax to get the content from sharepoint
var fileCollectionEndpoint = "https://graph.microsoft.com/v1.0/sites/yyyyyy.com/drives/folderiddd/items/id2222/workbook/worksheets('Sheet1')/charts('Chart 2')/Image(width=300,height=300,fittingMode='fit')";
$.ajax({
url: fileCollectionEndpoint,
async: false,
dataType: 'json',
type: "GET",
headers: {
'Authorization':'This is copied from the Microsoft graph explorer',
},
success: function (json) {
var imgsource ="data:image/png;base64,"+json.value;
$("body").append("<img id='ddd' src='"+imgsource+"' />");
}
});
The above code is working fine. But the problem is every one hour once this token getting expired I'm trying to generate the token using rest-api because everytime I can't copy paste from the Microsoft Graph Explorer. How can I do it?