Get Sharepoint Site Size

On 09/10/2025 0

In SharepointOnLine

const fetchOptions = {
    method: 'GET',
    headers: {
        'Accept': 'application/json;odata=verbose'
    }
};
let respList1 = await fetch(`yoursiteUrl/_api/site/usage`, fetchOptions);
if (!respList1.ok) {
    const errorDetails = await respList1.text(); // Get error details from the response
    console.error(`HTTP error! Status: ${respList1.status}, Details: ${errorDetails}`);
    let err = JSON.parse(errorDetails);
    console.error(`HTTP error! Status: ${respList1.status}, Details: ${err.error.message.value}`);
    console.log(err.error.message.value);
    throw new Error(`HTTP error! Status: ${respList1.status}`);
}
const usage = await respList1.json();
console.log("usage", `${usage.d.Usage.Storage/ (1024 * 1024 * 1024)} Gb`);
        
 
No ratings yet - be the first to rate this.

Add a comment

Anti-spam