Can I get/put OneNote RAW page data? - onenote-api

I'm trying to backup/restore the OneNote contents on a business site.
Currently the API returns the HTML translated content of a Page, but some extensions or Ink data is missing.
Well, I did see Beta status API for Ink data. But why don't just get the whole data as it is, and restore it as it was?
I also know OneNote data is synced on OneDrive storage, but downloading as it is and restore it with Graph API doesn't work.
I need to parse the HTML and download the resources again and if there's some missing content then I have to wait for another beta API. And when restore I have to construct a multi-part request.
Can you please provide additional API for downloading/uploading the RAW content?
Thanks in advance.

This isn't supported by the OneNote API. In theory, you could use the OneDrive API to download the notebook as a folder or section as a file, which would have all the information.

Related

How to automatically fill in proposed code changes in the "Edit" URL for a GitHub file?

EDIT: See comments on Schwern's answer for what I'm looking for in general. It doesn't have to be exactly what I'm asking for in the question
I have a web app which is an editor. I would like users to be able to give me a GitHub file URL, my app would automatically load in the file from GitHub, and then I make a process for them which is as easy as possible to submit that change to GitHub again. Ideally the user wouldn't need to save / upload a file or do any copy/pasting.
GitHub has a URL scheme where you can go to an "Edit" page for a file, make your changes, and then create a PR or create a commit (depending on what you would like to do and your permissions). This is an example:
https://github.com/rails/rails/edit/main/README.md
Looking at the HTML for the form I see that some of the fields have names associated. Using those names I can auto-fill the commit title and description:
https://github.com/rails/rails/edit/main/README.md?message=foo&description=bar
But I can't find a way to automatically fill in/replace the actual contents of the file. Is there a way?
I realize that for some browsers URLs can only be so long (maybe that's not true anymore?), so maybe this isn't perfect. I'd also be open to other suggestions on how to accomplish what I'm looking for.
Don't try to do this via web scraping, it's fragile and slow. Use the Github API.
Specifically, you'd get access via OAuth, get the file, let the user edit it, and then send the edited version.
There is no way to do exactly what you want. The ideal tool for this job is an OAuth App. However, creating one with the GitHub API requires that you store a client ID and a client secret, and there is no secure way to store the client secret in a frontend-only app.
Therefore, you'll need to create a backend to create the OAuth app so that you can issue credentials necessary to use the API on behalf of the user or to push data into the repository via the standard protocols.
As Schwern mentioned, you should not try to do this by driving the GitHub web interface. That isn't a stable interface and may break at any time.

Best approach to upload the file via REST api from API gateway

User Case: Customer can upload the file from the public REST api to our S3 bucket and then we can process the file using downstream services.
After doing some research I am able to find 3 ways to do it:
Uploading using OCTET-STREAM file type
Upload the file using form-data request
Upload the file using the pre-signed URL
In first 2 cases user will send the binary file and we will upload the file to S3 after file validation.
In the 3rd method user have to hit 3 apis. First API to get the S3 pre-signed URL which will give access to the user to upload the file to S3. In second hit user will upload the file to that s3 pre-signed URL. After the user complete the upload he will send the request to process the file.
Do we have any security issues with step 3? As user can misuse the pre-signed URL with malicious file.
Which of these method is best according to industry practice?
Details of each approach:
1. Uploading using OCTET-STREAM file type
Pros:
This method is good to upload file types which can be opened in some application such as xlsx.
1 API hit. Direct file upload
Cons:
This option is not suitable to upload multiple files. If in future we need to support multiple file upload this should be changed to multipart/form-data (A2).
No metadata can be send as body parameter. Metadata can be send in headers.
2. Upload the file using form-data request
User will upload the file with the API request by attaching it as multipart form.
Pros
We can send multiple files at the same time.
We can send extra parameters in the body.
3. Upload the file using the pre-signed URL
Cons
Customer have to hit the 3 APIs to upload the file. (2 API hits to upload and then 1 more API hit to check the process the file)
If you want them to load data into a bucket, the best way will almost always be the pre-signed URL. This gives you complete control over how you hand out access to the bucket, but also allows them to directly upload into the bucket when they have the access.
In the first two examples the user can send malicious data to your API, potentially DOSing the server / incurring costs on you to manage the payloads as you have no control over access (it is public).
In the third case they can request a URL from you, but that is it, other than spamming you for requests for URLs, unless you grant them a URL they can't access the bucket or do anything else. This seems much better than spamming your upload with large junk files and having you process them before you decide you didn't want them anyway.
Finally using the pre-signed URL is the pattern AWS would expect you to use, and so have a lot of support for managing the access, roles, logging and monitoring etc that you would want to put around this service. When you are standing up the API yourself this will all be up to you to manage.

How can I view a raw text file on GitHub permanently?

How can I view a raw text file on GitHub?
I created an unlisted REPO and inside the repo is a text file.
When I view it in raw format I get exactly what I want. And if I use C# to Download the text of that page, I get what I want.
My only concern is that the link to the github raw file is
https://raw.githubusercontent.com/USERNAME/STUFF/master/version.txt?token=THETOKEN
Does the THETOKEN part ever change? Like can I use this link for the rest of my life to access that raw text file? Or does the link change?
The token part is an auth token so it will work as long as that set of credentials is valid (until you revoke it). However, you should still manage that token as a secret.
If you plan to share this C# program with others you should not share your token with them, since this will give them access to other parts of your GitHub account.
If you want to share this file publicly you should publish it to a public CDN or another service that provides access control. For example you can use Amazon S3 with signed URLs for a few cents a month.

What is maximum file size to upload via Dropbox API v2?

I am trying to upload files to Dropbox using API v2 /upload endpoint. Sometimes I get a 413 error response from the Dropbox server (Request entity too large).
Unfortunately, maximum file size is not described in the documentation, maybe someone know about it?
Sorry, we'll add this to the documentation.
I'm pretty sure the limit is unchanged from API v1, so it's 150MB. Beyond that, you should use /upload/session/*.

Connecting GWT widget and JIRA

I have a GWT screen in which i have a file upload bar,whenever i attach something and click send,the request should go on server side which in turn logs an JIRA request with attachment as the same which was attached to my GWT widget.
Not able to code it.
I've made the particular widget. Server side processing which includes raising JIRA request is remaining.
Please help.
Thanks
If you need to upload an attachment to a JIRA issue I would recommend you to use the JIRA built-in REST API.
See information on the operation of attachment POST here: https://developer.atlassian.com/static/rest/jira/4.4.1.html#id149632
And general information on REST implementation here:
https://developer.atlassian.com/display/JIRADEV/JIRA+REST+APIs
So basically the process would be as follows: You initiate upload from client side to your server, your server validates the file and then uploads file to JIRA via the REST API.