Graph API errors that we cannot control - microsoft-graph-api

We are working on an automation that reaches out to Graph API on a schedule (every 5 minutes) and manipulates some worksheets.
Most of the times it works fine, but sporadically, we're running into a errors coming from the API that we cannot control, here's the most frequent:
Status: 504
cannot POST /v1.0/me/drive/items/<docid>/workbook/createSession (504)
Is this a known issue? Or are we doing something wrong?
And sometimes, the error comes in a totally bizarre way, as html:
StatusError: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <title>404 - File or directory not found.</title> <style type="text/css"> <!-- body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;} fieldset{padding:0 15px 10px 15px;} h1{font-size:2.4em;margin:0;color:#FFF;} h2{font-size:1.7em;margin:0;color:#CC0000;} h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF; background-color:#555555;} #content{margin:0 0 0 2%;position:relative;} .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;} --> </style> </head> <body> <div id="header"><h1>Server Error</h1></div> <div id="content"> <div class="content-container"><fieldset> <h2>404 - File or directory not found.</h2> <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3> </fieldset></div> </div> </body> </html> at s (/var/task/dist/index.js:1:8872) at <anonymous> at process._tickDomainCallback (internal/process/next_tick.js:228:7) name: 'StatusError', status: 404, code: 'UnknownError', agent: 'cannot POST /v1.0/me/drive/items/01MFBSIOQF7YVAPATDUJEI2LJAMXXGERX3/workbook/createSession (404)' }

Related

ReDoc cannot display a local OpenAPI definition file

ReDoc displays a remote openapi.json normally:
<?xml version="1.0" encoding="UTF-8"?><html>
<head>
<title>ReDoc - openapi.json</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<redoc spec-url="https://petstore3.swagger.io/api/v3/openapi.json"/>
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js">/**/</script>
</body>
</html>
But if I save openapi.json locally
<?xml version="1.0" encoding="UTF-8"?><html>
<head>
<title>ReDoc - openapi.json</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<redoc spec-url="file:///tmp/openapi.json"/>
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js">/**/</script>
</body>
</html>
it shows this error:
Something went wrong...
process is not defined
Stack trace
resolve#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:301803
resolveExternalRef#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:76499
4182/resolveDocument/<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:77225
4182/r</<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:74930
4182/r<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:74675
resolveDocument#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:77178
3675/t.bundle/<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:33256
3675/r</<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:28947
3675/r<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:28692
3675/t.bundle#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:33035
n#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:579
Mu/</n/e<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1021
Mu/</n/e<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:837
n#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1040
Mu/</<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1261
Mu/</<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1077
Mu/<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:117:1280
Il#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:488153
53/t.unstable_runWithPriority#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:517125
Wo#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:428837
Rl#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:487616
4448/Cl/<#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:487527
D#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:516186
53/w.port1.onmessage#https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js:8:514909
ReDoc Version: 2.0.0
Commit: 5fb4daa
How to display a local OpenAPI definition file with ReDoc?
The easiest way is with Redocly CLI:
npx #redocly/cli preview-docs openapi.json
Source: https://redocly.com/docs/cli/commands/preview-docs/

Why SvelteKit basic example build output use the very modern import keyword?

In the description of Svelte, Rich explained why it's important to use the import keyword for development, and I'm totally agree. He continues and says that in the production build it's using the traditional JavaScript packaging:
That's not to say we're abandoning bundlers altogether. It's still essential to optimise your app for production, and SvelteKit uses Rollup to make your apps as fast and lean as they possibly can be (which includes things like extracting styles into static .css files).
But when I'm building the famous example from npm init svelte#next with adapter set to node, I see that the output JavaScript still use the import keyword in the pages JS, and also use <link rel="modulepreload" ...> which is super modern for browsers, as mentioned. For example, here is the output HTML of the built for production index.html page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Home</title>
<link rel="modulepreload" href="/_app/start-331a94d4.js">
<link rel="modulepreload" href="/_app/chunks/vendor-a4e104ac.js">
<link rel="modulepreload" href="/_app/pages/__layout.svelte-ad0878a7.js">
<link rel="modulepreload" href="/_app/pages/index.svelte-49c07d7e.js">
<link rel="stylesheet" href="/_app/assets/start-61d1577b.css">
<link rel="stylesheet" href="/_app/assets/pages/__layout.svelte-a06e2686.css">
<link rel="stylesheet" href="/_app/assets/pages/index.svelte-1ae03b51.css">
<script type="module">
import { start } from "/_app/start-331a94d4.js";
start({
target: document.querySelector("#svelte"),
paths: {"base":"","assets":""},
session: {},
host: "127.0.0.1:3000",
route: true,
spa: false,
trailing_slash: "never",
hydrate: {
status: 200,
error: null,
nodes: [
import("/_app/pages/__layout.svelte-ad0878a7.js"),
import("/_app/pages/index.svelte-49c07d7e.js")
],
page: {
host: "127.0.0.1:3000", // TODO this is redundant
path: "/",
query: new URLSearchParams(""),
params: {}
}
}
});
</script>
</head>
<body>
<div id="svelte">
<header class="svelte-1twf6mk"><div class="corner svelte-1twf6mk"><img src="/_app/assets/svelte-logo-87df40b8.svg" alt="SvelteKit" class="svelte-1twf6mk"></div>
<nav class="svelte-1twf6mk"><svg viewBox="0 0 2 3" aria-hidden="true" class="svelte-1twf6mk"><path d="M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z" class="svelte-1twf6mk"></path></svg>
<ul class="svelte-1twf6mk"><li class="svelte-1twf6mk active"><a sveltekit:prefetch href="/" class="svelte-1twf6mk">Home</a></li>
<li class="svelte-1twf6mk"><a sveltekit:prefetch href="/about" class="svelte-1twf6mk">About</a></li>
<li class="svelte-1twf6mk"><a sveltekit:prefetch href="/todos" class="svelte-1twf6mk">Todos</a></li></ul>
<svg viewBox="0 0 2 3" aria-hidden="true" class="svelte-1twf6mk"><path d="M0,0 L0,3 C0.5,3 0.5,3 1,2 L2,0 Z" class="svelte-1twf6mk"></path></svg></nav>
<div class="corner svelte-1twf6mk"></div>
</header>
<main class="svelte-1izrdc8">
<section class="svelte-mjk9ig"><h1 class="svelte-mjk9ig"><div class="welcome svelte-mjk9ig"><picture><source srcset="svelte-welcome.webp" type="image/webp">
<img src="svelte-welcome.png" alt="Welcome" class="svelte-mjk9ig"></picture></div>
to your new<br>SvelteKit app
</h1>
<h2>try editing <strong>src/routes/index.svelte</strong></h2>
<div class="counter svelte-ltn89m"><button aria-label="Decrease the counter by one" class="svelte-ltn89m"><svg aria-hidden="true" viewBox="0 0 1 1" class="svelte-ltn89m"><path d="M0,0.5 L1,0.5" class="svelte-ltn89m"></path></svg></button>
<div class="counter-viewport svelte-ltn89m"><div class="counter-digits svelte-ltn89m" style="transform: translate(0, 0%)"><strong style="top: -100%" aria-hidden="true" class="svelte-ltn89m">1</strong>
<strong class="svelte-ltn89m">0</strong></div></div>
<button aria-label="Increase the counter by one" class="svelte-ltn89m"><svg aria-hidden="true" viewBox="0 0 1 1" class="svelte-ltn89m"><path d="M0,0.5 L1,0.5 M0.5,0 L0.5,1" class="svelte-ltn89m"></path></svg></button>
</div>
</section></main>
<footer class="svelte-1izrdc8"><p>visit kit.svelte.dev to learn SvelteKit</p>
</footer>
</div>
</body>
</html>
How can I build SvelteKit with the node adapter, with the traditional JavaScript rollupjs output in the client code, e.g. without the import keyword?
It turns out that my question is a feature request for SvelteKit.
This will be done after releasing version 1.0 of SvelteKit.
Credit for dummdidumm for pointing me out for this while I opened a duplicated issue.

How to force a page break in HtmlRenderer.PdfSharp?

I'm using "HTML Renderer for PDF using PDFsharp" HtmlRenderer.PdfSharp (version 1.5.1-beta1). I'm trying to force a page break. But I can't get this to work. What I have now in my html is this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Test</title>
<style>
div { page-break-inside: auto; }
</style>
</head>
<body style="margin:0; padding:0;" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div>Page1</div>
<div>Page2</div>
</body>
</html>
Both div stay on the same page when I convert this html to PDF.
string contents = File.ReadAllText(#"C:\temp\test.html");
PdfDocument pdf = PdfGenerator.GeneratePdf(contents, PageSize.A4);
pdf.Save(#"C:\temp\pdfsharp.pdf");
How can I force the second div to a new page?
The only known solution to force page breaks is to split the html into parts, and generate a page for each html part. Solution from Grasher134 on GitHub: https://github.com/ArthurHub/HTML-Renderer/issues/49#issuecomment-251351431

Rails Internal Style For Mailer Template Not Working

Internal style written in rails mailer template is not working.
<html>
<head>
...
...
</head>
<body>
<style type="text/css">
...
...
</style>
</body>
</html>
How to solve this problem?
Make sure that you are putting internal style inside head tag
eg:
<head>
<style type="text/css">
...
...
</style>
</head>
Note: Only internal style (must be in head tag) supports.

What's adding <style type="text/css">body { display: none !important }</style>

I followed these instructions for my app:
https://github.com/yeoman/generator-angular#readme
My Index (before build)
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css(.) styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css(.tmp) styles/app.css -->
<link href="app.less" type="text/css" rel="stylesheet/less">
<!-- endbuild -->
My dist Index (in text-editor)
<html ng-app="myApp"> <head> <meta charset="utf-8"> <title>Datavalidering</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel="stylesheet" href="styles/vendor.2ac5f564.css"> <link rel="stylesheet" href="styles/app.d41d8cd9.css"> </head> <body>
Dist index (browser)
<head>
<style type="text/css">#charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}</style>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="styles/vendor.2ac5f564.css"> <link rel="stylesheet" href="styles/app.d41d8cd9.css">
<style type="text/css">body { display: none !important }</style></head>
<body>
The problem may be in gruntfile.js
http://plnkr.co/edit/r2hdhWY7olIw0pBHJ4VF?p=preview
Thank you in advance for your answers!
This happens because of (less.js):
// Simulate synchronous stylesheet loading by blocking page rendering
if (!options.async)
{
css = 'body { display: none !important }';
head = document.head || document.getElementsByTagName('head')[0];
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}
so, all you need to do is add this before less.js
<script>
less = {
async: true
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.6.1/less.min.js"></script>
I'm not using Angular, but had a similar problem where this <style type="text/css">body { display: none !important }</style> suddenly appears at the end of head tag, effectively renders the whole page to not displaying anything.
I found out that the culprit was less.js. Simply commenting the line fixes it.
I have found a solution and the culprit.
It comes from the "Jetpack".
This image shows the location of the code in WordPress Directory:

Resources