Updating Created Date in OneNote page with PATCH - microsoft-graph-api

Using Microsoft Graph, body, title, etc. seem easy to update, but I can't seem to figure out the right syntax for created date. I'm making a copy of a current page (only way to get lined pages, it seems) and want the created date to reflect when the target created date should be.
Here is the content in OneNote:
<head>
<title>New Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2019-07-22T09:00:00.0000000" />
</head>
I've tried
data=json.dumps([
{
"target": "meta: #created",
"action": "replace",
"content": "2019-07-23T09:00:00.0000000"
}
])
and
data=json.dumps([
{
"target": "created",
"action": "replace",
"content": "2019-07-23T09:00:00.0000000"
}
])
but get
{
"error": {
"code": "20134",
"message": "The Patch request message is invalid: The selected target meta: #created is not a valid updateable element.",
"innerError": {
"request-id": "156f1db9-a331-4ee4-96f8-15d90d393f63",
"date": "2019-06-12T12:25:54"
}
}
}
What would be the right syntax?

Patch the page's CreatedDate is not currently supported. How are you copying the page? If you use the Graph OneNote API https://learn.microsoft.com/en-us/graph/api/page-copytosection?view=graph-rest-1.0&tabs=cs won't you get the correct CreatedDate on the copied page?

You can set the Page title to the meeting time using Patch-pages-content with target=title

Related

iOS PWA opens same-domain links in overlay window instead of the same base window

I've created a progressive web app which is no single page application, but has regular links with page reloads.
I've added a manifest.json which looks like this:
{
"name": "MyApp",
"short_name": "MyApp",
"theme_color": "#4FD083",
"background_color": "#333333",
"display": "fullscreen",
"lang": "de-DE",
"scope": "my_domain.tld",
"start_url": "my_domain.tld",
"icons": [
/* Some icons */
]
}
When I visit the page in iOS Safari and add it to the home screen, the first time I open it it doesn't have a header and footer bar (which is correct). But once I click any link within the "app", it opens the content of this link in an overlay window which has a "Done" button and some icons on top (which is not correct). Looks like this:
I want all links on the same domain (which I would expect is defined by the scope attribute in manifest.json) to open in the same "window", respecting the "fullscreen" or "standalone" value of the "display" attribute in manifest.json.
I also tried playing around with these meta tags, but to no avail:
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
It works as expected on Android (Chrome).
Am I doing anything wrong?
I got it working. I basically did three things, but am not certain which of it does the trick:
Add the manifest.json (code below)
Add a fake webServiceWorker (code below)
Add some meta tags
manifest.json
{
"name": "AppName",
"short_name": "AppName",
"description": "Some Description",
"lang": "de-DE",
"start_url": "/",
"scope": "/",
"display": "standalone",
"theme_color": "#4FD083",
"background_color": "#4FD083",
"icons": [
{
"src": "/img/apple-touch-icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/img/apple-touch-icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
webServiceWorker #1
<script type="text/javascript">
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('js/service-worker-pwa.js');
}
</script>
webServiceWorker #2 (the actual file as referenced above)
self.addEventListener('fetch', function (e) {
});
self.addEventListener('install', function (event) {
});
meta tags
<link rel="manifest" crossorigin="use-credentials" href="<url of the application>/manifest.json">
<meta name="application-name" content="AppName">
<meta name="msapplication-starturl" content="<url of the application>">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="AppName" />
Hope this will be helpful for anyone else running into this issue.

Fullscreen PWA on Safari iOS13 iPad has URL bar with reader and "Done" button, unable to hide

I have a web app that I've added to the homescreen on my iPad as a PWA. All was fine prior to the iOS13 update, in which now there is a small URL toolbar at the top the has "Done" on the left (refreshes/reloads page to initial start URL) and a Reader/Settings "Aa" button on the right.
The URL bar only appears when a user logs in, in which their session data is encrypted and added at the end of the URL, so it goes from "https://mysite/Home/" to "https://mysite/Home/encryptedsessionurl". As far as I know, having the scope in my manifest (below) be "https://mysite/Home/" should be alerting Safari that this is the same site, but it is not.
I have read multiple posts trying to figure this out-- I've checked my meta tags, and created a manifest.json file which looks like this:
{
"name": "My App Name",
"short_name": "My App",
"lang": "en-US",
"display": "standalone",
"orientation": "landscape",
"start_url": "https://mysite/Home/",
"scope": "https://mysite/Home/",
"permissions": [
"unlimitedStorage",
"fullscreen"
]
}
My meta-tags looked like this, which were functioning fine before:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-status-bar-style" content="black" />
I've tried removing the meta-tags and only having the manifest, as another post suggested, and have even tried changing display: "standalone" to "fullscreen" in the manifest which also has not worked.
I'm just not sure what's wrong here, and any other suggestions would be greatly appreciated.
Maybe a silly mistake, but hopefully it will help others as well-- I didn't realize that I had to keep creating a new PWA for the site every time I updated my manifest.
It started working perfectly the moment I created a new PWA (via "Add to Homescreen" shortcut).

Adding new divs (blocks of content) inside OneNote page using the Microsoft Graph API

I am using the Microsoft Graph API to programmatically add content to a OneNote Page on my Office365 OneNote Notebook. For an example page like this:
OneNote snip consisting of Title & 2 separate divs/blocks, this is the generated HTML that I get by making a GET to the pages/{myPageID}/content?includeids=true endpoint
<html lang="en-US">
<head>
<title>Thursday, December 6, 2018</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2018-12-06T19:55:00.0000000" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{95790d05-168a-4f61-81a7-5c13e3124069}{4}" style="position:absolute;left:48px;top:115px;width:624px">
<p id="p:{95790d05-168a-4f61-81a7-5c13e3124069}{10}" style="margin-top:0pt;margin-bottom:0pt">It is a jolly good day</p>
</div>
<div id="div:{3a6b78e9-2af8-4a5b-abf8-09871fb6eec5}{20}" style="position:absolute;left:44px;top:180px;width:624px">
<p id="p:{3a6b78e9-2af8-4a5b-abf8-09871fb6eec5}{24}" style="margin-top:0pt;margin-bottom:0pt">Lets do this shall we</p>
</div>
</body>
</html>
I now try adding a new div/block by making the following PATCH using the requests library in Python. The myPageID and access_token are collected previously by making GET requests to the graph API:
patchPageURL='https://graph.microsoft.com/v1.0/users/'+userID+'/onenote/pages/'+myPageID+'/content?includeIDs=true'
patchPageHeaders={
'Content-Type':'application/json',
'Authorization':'Bearer '+access_token
}
patchPageBody=[{
'target':'div:{3a6b78e9-2af8-4a5b-abf8-09871fb6eec5}{20}',
'action':'insert',
'position':'after',
'content':'<div><p> And God said let there be new blocks </p></div>'
}]
patchResp = requests.patch(patchPageURL, headers=patchPageHeaders, json=patchPageBody)
However, I end up with a 400 error as a response to my PATCH request with the following code and message:
code: 20135
message: The entity type is not supported for this operation.
If I change the opening div tag for the content to something like <div data-id="new-div">, I still receive the same 400 error, code 20135.
I am following the instructions from this documentation here. What subtlety is being missed here? There are no authentication or other similar errors. The PATCH works fine if I change the target to body and the action to append but that doesn't make a new div/block and only adds the content as a child of the first div in the page.
Is there a straightforward way to add new blocks/divs as a sibling of existing blocks or even just something as simple as adding a new block at the end of the OneNote page?

UI5 Mock Server with Local Data: "rootUri" Not Working

I'm currently following the UI5 tutorial and am stuck on step 27: Mock Server Configuration.
The problem is the rootUri configuration of the mock server. I am using the Northwind OData service as per tutorial and have configured a dataSource for Invoices in the manifest.json.
Now, to use the local mock data instead of the online service, I created the necessary files as stated by the tutorial. When I then run the mockServer.html, the server doesn't redirect the service request to the local mock data, but instead makes the request and fails because of web security issues.
If I use the following rootUri, the mock server doesn't redirect and the service request fails:
// Snippet from mockserver.js
var oMockServer = new MockServer({
rootUri: "/destinations/northwind/V2/Northwind/Northwind.svc/"
});
Failed to load https://services.odata.org/V2/Northwind/Northwind.svc/$metadata?sap-language=DE:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://webidetesting9515320-s0015250556trial.dispatcher.hanatrial.ondemand.com' is therefore not allowed access.
The response had HTTP status code 501.
Another question on Stackoverflow shows the mock server using a "wildcard" root-uri, but this also fails:
// Snippet from mockserver.js
var oMockServer = new MockServer({
rootUri: "/"
});
The only way I can make the mock server configuration work is to use the exact same URL as the rootUri that is written in the manifest.json as the URI of the dataSource I want to mock:
// Snippet from mockserver.js
var oMockServer = new MockServer({
rootUri: "https://services.odata.org/V2/Northwind/Northwind.svc/"
});
The above code works, but the Web IDE states that this is a bad practice:
error: Fiori Architectural Guidelines: ESLint(sap-no-hardcoded-url): Hardcoded (non relative) URL found. (img)
My question now is: How can I make the mock server run the intended way with a relative rootUri?
webapp/manifest.json (excerpt)
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "sap.ui.tutorial.walkthrough",
"type": "application",
"i18n": "i18n/i18n.properties",
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"applicationVersion": {
"version": "1.0.0"
},
"dataSources": {
"invoiceRemote": {
"uri": "https://services.odata.org/V2/Northwind/Northwind.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0"
}
}
}
},
...
webapp/test/mockServer.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<title>Hello World App - Test Page</title>
<script src="/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-theme="sap_belize"
data-sap-ui-libs="sap.m"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"
data-sap-ui-resourceroots='{
"sap.ui.tutorial.walkthrough": "../"
}'></script>
<script type="text/javascript">
sap.ui.getCore().attachInit(function() {
sap.ui.require([
"sap/ui/tutorial/walkthrough/localService/mockserver",
"sap/m/Shell",
"sap/ui/core/ComponentContainer"
], function(mockserver, Shell, ComponentContainer) {
mockserver.init();
new Shell({
app: new ComponentContainer({
name: "sap.ui.tutorial.walkthrough",
height: "100%"
})
}).placeAt("content")
});
});
</script>
</head>
<body class="sapUiBody" id="content">
</body>
</html>
webapp/localService/mockserver.js
sap.ui.define([
"sap/ui/core/util/MockServer"
], function (MockServer) {
"use strict";
return {
init: function () {
// create
var oMockServer = new MockServer({
rootUri: "https://services.odata.org/V2/Northwind/Northwind.svc/"
});
var oUriParameters = jQuery.sap.getUriParameters();
// configure
MockServer.config({
autoRespond: true,
autoRespondAfter: oUriParameters.get("serverDelay") || 1000
});
// simulate
var sPath = jQuery.sap.getModulePath("sap.ui.tutorial.walkthrough.localService");
oMockServer.simulate(sPath + "/metadata.xml", sPath + "/mockdata");
// start
oMockServer.start();
}
};
});
webapp/localService/metadata.xml
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="NorthwindModel" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Invoice">
<Key>
<PropertyRef Name="ProductName"/>
<PropertyRef Name="Quantity"/>
<PropertyRef Name="ShipperName"/>
</Key>
<Property Name="ShipperName" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false"
Unicode="true"/>
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" FixedLength="false"
Unicode="true"/>
<Property Name="Quantity" Type="Edm.Int16" Nullable="false"/>
<Property Name="ExtendedPrice" Type="Edm.Decimal" Precision="19" Scale="4"/>
</EntityType>
</Schema>
<Schema Namespace="ODataWebV2.Northwind.Model" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="NorthwindEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true"
xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="Invoices" EntityType="NorthwindModel.Invoice"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
There are some rules to watch out for when it comes to defining the rootUri for mock server.
The rootUri
Should be relative
Has to end with a slash ("/")
Has to match with the URI that is assigned to your model.
It is mentioned in the step 27:
(The rootUri) matches the URL of our data source in the descriptor file.
As well as in the topic Mock Server: Frequently Asked Questions:
The root URI has to be relative and requires a trailing '/'. It also needs to match the URI set in OData/JSON models or simple XHR calls in order for the mock server to intercept them.
So it doesn't matter how your rootUri is defined as long as it fulfills those three requirements mentioned above. That's why some arbitrary URIs like rootUri: "/" works as well but only if the uri in the dataSource is the same.
In your case, changing the rootUri value like this below should make the mock server running:
var oMockServer = new MockServer({
rootUri: "/destinations/northwind/V2/Northwind/Northwind.svc/"
});
And in your app descriptor (manifest.json) respectively..:
"dataSources": {
"invoiceRemote": {
"uri": "/destinations/northwind/V2/Northwind/Northwind.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0"
}
}
}
To make the path work in a non-MockServer scenario, you'll need to register a corresponding destination in SAP Cloud Platform and edit neo-app.json in your project accordingly.
No need to change the application code.
Some details of chapter 27 of the tutorial are quite misleading.
The rootUri of the MockServer must match the uri parameter of the datasource in manifest.json.
Instead of changing datasource's uri to the (wrong) rootUri of MockServer given in the tutorial, you should actually change MockServer's rootUri to the URI of the external source. In webapp/localService/mockserver.js use this corrected block:
var oMockServer = new MockServer({
rootUri: "https://services.odata.org/V2/Northwind/Northwind.svc/"
});
This will create a MockServer that intercepts all calls to that external URI and responds to them locally. And with this construct, it is actually possible to access the MockServer through /webapp/test/mockServer.html and the live data server through /webapp/index.html.
Hint:
You will most likely still have trouble accessing the original (external) data source using /webapp/index.html due to Same Origin Policy restrictions (SOP). With Google Chrome this can be nicely solved by running a second (!) instance of the browser without SOP. This is possible in parallel to other open browser windows of the standard instance WITH SOP, so you don't need to close all your open browser windows. See this answer for details.

Postman - Push GCM to iOS with Postman

I am trying to test GCM to my app with Postman. But It is not authorized.
In the header i put for
Key : The Server key (auto created by Google Service)
Value : application/json
And in Body - Raw :
{ "data": {
"score": "5x1",
"time": "15:10"
},
"to" : "lKVLmzMmvoU:APA91bFrbpmT4IAxS-rN9sr_y8-YDgrySaC7bMx3Pm_Qd-uEb7dfMnMaJRvNfPTj9c1YdhBJp6ClbsIvMKogmet9V0-HV_sgkBNUx59Rq25Ccbys0NWuuh_Mpd7ryK-98pxRV7B2WW63"
}
The value for "to" is the token I got from the GCM Registration.
But I have this response :
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
Thank you !
Each line within Postman is a key-value pair, your values should look something like this:
Postman have a great guide here with lots more helpful tips.

Resources