OneNote body is not sent when using non-multipart REST - rest

I'm having some issues when I try to create a note using OneNote REST API.
This happens in my application and also when I try to use for testing purpose the apigee tool: https://apigee.com/onenote/embed/console/onenote
After some tests, i've tested the example available on OneNote documentation:
http://msdn.microsoft.com/en-us/library/office/dn575438(v=office.15).aspx#sectionSection3
On apigee, I have the following parameters:
Method: POST
Header: Content-Type: text/html and the corresponding authorization token.
Request Body:
<!DOCTYPE html>
<html>
<head>
<title>One Simple Note</title>
<meta name="created" content="2013-06-11T12:45:00.000-8:00"/>
</head>
<body>
<p>This is a simple non-multi-part HTML page.</p>
</body>
</html>
The note is sent successfully and I receive 201.
When I check my OneNote page, the note is created, but the body of the note is empty.
What am I doing wrong?

Turns out we had a bug in our system that caused messages under 16kb to be ignored. We just fixed it, so you shouldn't have any problems now!

Related

Facebook Instant Articles HTML POST Error

I've hit a blocker with POST'ing of HTML content to the https://graph.facebook.com api. I'm able to successfully POST to the endpoint and I receive a status ID as a response. When I then use a GET on the endpoint to check the status, the error messages tell me my content is malformed. I'm able to manually publish the exact same HTML content on my channel in Instant Articles and I get no warnings about the formatting of the HTML. I've also tried using the sample article HTML provided by Facebook and that returns error messages as well. Any advice is appreciated. Here are samples of my requests:
POST /{my_page_id}/instant_articles?access_token={my_access_token}& html_source=<!DOCTYPE html><html lang="en" prefix="op: http://media.facebook.com/op HTTP/1.1
Host: graph.facebook.com
cache-control: no-cache
Postman-Token: {postman_token}
<!---Facebook Sample Article Content--->
<!doctype html>
<html lang="en" prefix="op: http://media.facebook.com/op#">
<head>
<meta charset="utf-8">
<!--Canonical URL of the article from site -->
<link rel="canonical" href="{my_Facebook_approved_domain/canonical_url}">
<link rel="stylesheet" title="{my_stylesheet}" href="#">
<!--Article Title-->
<title>{my_article_title}</title>
<meta property="fb:article_style" content="{my_stylesheet}">
</head>
<body>
<article>
<header>
<!-- The header image shown inside your article -->
<figure>
<!-- First Figure from the article -->
<img src="{my_image_url}">
</figure>
<!-- Article Title -->
<h1>{my_article_title}</h1>
<!--Article Teaser-->
<h2>{my_article_subtitle}</h2>
<!-- The authors of the article -->
<address>{list_of_authors}</address>
<!--The published and last modified time stamps-->
<time class="op-published" dateTime="2019-01-10T16:00">January 10 2019, 04:00 PM</time>
</header>
<p>{my_content}</p>
<p> Read the Full Story at {my_site}</p><br>
<footer>
<!-- Copyright details for your article -->
<small>© 2019 {my_site}. All Rights Reserved.</small>
</footer>
</article>
</body>
</html>
After submitting the POST request, I get a response that looks like this:
{
"id": "2005563182874064"
}
I then GET the article status endpoint by calling:
GET /{page_id}?access_token={my_access_token}& fields=errors,html_source,instant_article,status HTTP/1.1
Host: graph.facebook.com
cache-control: no-cache
Postman-Token: {postman_token}
...and the response I get from that endpoint is as follows:
{
"errors": [
{
"level": "ERROR",
"message": "AttValue: \" expected"
},
{
"level": "ERROR",
"message": "Couldn't find end of Start Tag html"
},
{
"level": "ERROR",
"message": "Missing Article's Canonical URL: There is no URL specified for this article. A canonical URL needs to be claimed and placed within the HTML to generate an Instant Article. Refer to URLs under Publishing Articles in the Instant Articles documentation for more information on claiming and inserting a canonical URL."
}
],
"html_source": "<!DOCTYPE html><html lang=\"en\" prefix=\"op: http://media.facebook.com/op",
"status": "FAILED",
"id": "2005563182874064"
}
The canonical URL is certainly present in my HTML and I've tripled checked that it's listed in the Configuration/Tools/Connect your site area of my Facebook page. Again, I'm able to manually upload the same HTML and preview it using the Pages App on a mobile device. It's only failing when I try to push the content via the API.
I'm testing all of my calls with POSTMAN and will then convert this code to Python3. Again, thanks for your help.
You always want to place payload data in the body of the request for POSTs and as a query string for GET. Anytime an API calls for data that looks extreme for a URL (can't be longer than 2083 characters), that's a key indicator that this is probably not a GET.

Facebook iframe self hosted app not displayed

I am currently integrating a HTML5 app into Facebook and testing the iFrame mechanism. I am self-hosting the game content however when I point the Facebook app system to the content, the page is not being displayed.
My hosted page is a simple Hello World app for now as illustrated below, and can be found at: https://bluebeck.space/alienz/fb/
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta charset="utf-8">
<title>Alienz</title>
</head>
<body>
<div><p>Hello, World!</p></div>
</body>
</html>
The app configuration in the Facebook app developer console appears as:
I have used the following HTTPS url which has a valid SSL certificate as required:
The app page contents are empty and upon inspection of the Facebook app page DOM, it is apparent that the iframe contents have been stripped from the hosted page:
My expected result would be that the contents of the self-hosted webpage would be visible in the Facebook app page. The actual result is that the contents are empty and the DOM contains an iframe tag with empty head and body tags.
Thanks to #cbroe I was able to pin this down to an X-Frame-Options error. My solution has been to include the following php headers to the page:
<?php
header('X-Frame-Options: ALLOW-FROM https://apps.facebook.com/');
header('Content-Security-Policy: frame-ancestors https://apps.facebook.com/');
?>

401 Unauthrorized response while creating a Rest API instance?

I'm trying to send a POST request on http://xyz:8002/LATEST/rest-apis using Firefox's rest client. I have added two headers Content-Type: application/xml and Authorization:Basic which I selected using the dropdown UI. The body of the request is -
<rest-api xmlns="http://marklogic.com/rest-api">
<name>Status Dashboard</name>
<database>r75-xyz-v11</database>
<port>8020</port>
</rest-api>
In response I'm getting a 401 Unauthoried.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>401 Unauthorized</title>
<meta name="robots" content="noindex,nofollow"/>
</head>
<body>
<h1>401 Unauthorized</h1>
</body>
</html>
I have Admin rights and I gave the same credential in the UI box that came after selecting authentication basic.
Is port 8002 configured for BASIC or DIGEST (the default) authentication?
By the way, I don't think the name of the appserver can contain a space.

OneNote REST API - The multi-part payload was malformed

I am working on an integration with OneNote using the REST API.
I'm trying to create a note but I'm always receiving 400 response code, with the following message: "The multi-part payload was malformed."
URL:
https://www.onenote.com/api/v1.0/pages
Headers:
Content-Type: multipart/form-data; boundary=NewPart
Authorization: Bearer myToken
--NewPart
Content-Type: text/html
Content-Disposition: form-data; name="Presentation"
<!DOCTYPE html>
<html>
<head>
<title>One Note test</title>
<meta name="created" content="2014-04-13T10:36:28+01:00"/>
</head>
<body>
<p>Hello OneNote World</p>
</body>
</html>
--NewPart--
If I try the same request in the apigee tool (https://apigee.com/onenote/embed/console/onenote), it's working perfectly.
I have initially tried to not use multi-part, but all the notes sent without multi-part were missing the note body on the OneNote site. Here is my post on this other issue:
OneNote body is not sent when using non-multipart REST
Make sure the presentation part lines end in CRLF. We've noticed that when using some tools like Fiddler, when you try to reissue and edit a previous request, it removes the CRLF endings from the lines.

Getting the address of embedded GWT application

I have a question regarding the embedding of a GWT application.
The problem concerns getting the address of the client, and match it to the ip in the tag's src attribute. So the structure is Host html page (hosted on server a), embedding a gwt application hosted on server b.
<!DOCTYPE HTML>
<html dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Embedding gwt app</title>
<script type="text/javascript" src="http://192.168.0.1:8080/myapp/myapp.nocache.js?rootpanel=divone"></script>
</head>
<body>
<div id="divone" style="width:100px;height:100px;"></div>
</body>
</html>
What we have tried before is get the host path by using GWT.getHostPageBaseURL(), but this returns the host page's ip (we expected this..)
Are we trying to achieve something impossible? considering that the script file gets downloaded first, and then the onModuleLoad gets called when the script is ready on the client.
You can make a RPC request to the server side, and the server can do the following to get the client's IP: getThreadLocalRequest().getRemoteAddr();
Or if you don't want to make a request and want to do the work on the client side, you can make a GWT native JS method and try one of the suggestions from this stackoverflow post: How to get client's IP address using javascript only?