onenotedev / onenoteclassnotebookapisamplepowershell Goto Github PK
View Code? Open in Web Editor NEWCode sample with examples of how to use the OneNote Class Notebooks API on PowerShell
License: MIT License
Code sample with examples of how to use the OneNote Class Notebooks API on PowerShell
License: MIT License
Not sure what I am doing wrong, but when I try to insert a PDF using the OneNote API the PDF is unreadable and doesn’t render.
$tokenfile = get-content <…snip…>.json | ConvertFrom-Json
$access_token = $tokenfile.$access_token
foreach ($file in gci "/Users/steven/Documents/Receipts/2020 Receipts\*.pdf"){
$date = [datetime]::ParseExact($file.BaseName.Substring(0,17), 'yyyy-MM-dd HHmmss', $null)
$pdffile = [System.IO.File]::ReadAllBytes($file.FullName)
$pageContent = @"
--MyPartBoundary
Content-Disposition:form-data; name="Presentation"
Content-Type:text/html
<!DOCTYPE html>
<html>
<head>
<title>$($file.BaseName -replace ".pdf","")</title>
<meta name="created" content="$($date.ToUniversalTime().ToString('u').replace(' ','T'))" />
</head>
<body>
<p><img data-render-src="name:FileBlock" /></p>
<p><object data-attachment="$($file.name)" data="name:FileBlock" type="application/pdf" /></p>
</body>
</html>
--MyPartBoundary
Content-Disposition:form-data; name="FileBlock"
Content-Type:application/pdf
$pdfFile
--MyPartBoundary--
"@
Invoke-RestMethod -Uri 'https://graph.microsoft.com/v1.0/me/onenote/sections/<…snip...>/pages' `
-Method Post `
-ContentType 'multipart/form-data; boundary=MyPartBoundary' `
-Headers @{"Authorization" = "Bearer $($tokenfile.access_token)"} `
-Body $pageContent
}
This repository has had no activity in more than [x amount of time]. Long periods of inactivity present security and code hygiene risks. Archiving will not prevent users from viewing or forking the code. A banner will appear on the repository alerting users that the repository is archived.
Please see https://aka.ms/sunsetting-faq to learn more about this process.
✍️
❗**If this repository is still actively maintained, please simply close this issue. Closing an issue on a repository is considered activity and the repository will not be archived.🔒
If you take no action, this repository is still inactive 30 days from today it will be automatically archived..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.