Forum Discussion
Miike
Jul 04, 2024Brass Contributor
Terms of Use file download? How to access this via the Graph API
Hi All, I've started to play with Microsoft Graph in further details, but I'm having trouble with Terms of Use, I can retrieve the configuration and details on the file, but it would be great if ...
Miike
Jul 17, 2024Brass Contributor
I found it, I had to use dev tools in edge, request a file then look to see what it was requesting.
The following grabs the TOU file and converts it into the appropriate file:
# Make the request to get the file data
$fileDataResponse = Invoke-MgGraphRequest -Method GET -uri "https://graph.microsoft.com/v1.0/agreements/$($termsId)/file/localizations/$($fileId)/fileData/data" -ContentType "application/json"
# Decode the file data from Base64
$fileBytes = [Convert]::FromBase64String($fileDataResponse.value)
# Construct the full path to save the file
$outputFilePath = Join-Path -Path "$ExportPath\Terms of Use" -ChildPath $fileName
# Write the file data to the file
[System.IO.File]::WriteAllBytes($outputFilePath, $fileBytes)
The following grabs the TOU file and converts it into the appropriate file:
# Make the request to get the file data
$fileDataResponse = Invoke-MgGraphRequest -Method GET -uri "https://graph.microsoft.com/v1.0/agreements/$($termsId)/file/localizations/$($fileId)/fileData/data" -ContentType "application/json"
# Decode the file data from Base64
$fileBytes = [Convert]::FromBase64String($fileDataResponse.value)
# Construct the full path to save the file
$outputFilePath = Join-Path -Path "$ExportPath\Terms of Use" -ChildPath $fileName
# Write the file data to the file
[System.IO.File]::WriteAllBytes($outputFilePath, $fileBytes)