GithubHelp home page GithubHelp logo

onenotedev / onenoteclassnotebookapisamplepowershell Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 1.0 12 KB

Code sample with examples of how to use the OneNote Class Notebooks API on PowerShell

License: MIT License

PowerShell 100.00%

onenoteclassnotebookapisamplepowershell's People

Contributors

ivanhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

kurtdegreeff

onenoteclassnotebookapisamplepowershell's Issues

Problem adding PDF with PowerShell

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
}

[Action Needed] This repo is inactive

This GitHub repository has been identified as a candidate for archival

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.

Action

✍️

❗**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..

Need more help? 🖐️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.