SharePoint API: Create a page with custom HTML on a communications site - sharepoint

I need to create a new page on a SharePoint Communications Site programmatically, using the SharePoint APIs. The URL of this site looks like this: https://[sharepoint url]/sites/KnowledgeBase
And this is basically what I'm trying to do:
I am able to make authenticated requests to SharePoint using the REST API. I have that working in Postman. Unfortunately, I can't find any reliable documentation or a tutorial on how to create a new (modern) page with custom HTML content, using the REST API.
I was able to find this documentation on creating a page with the Graph API. However, I'm not sure if the Graph API is the right option, since it is still in beta, and the integration I'm building will go into Production.
Any help or insight on how to do this, and which API to use, would be really appreciated.

You could use Microsoft pnpjs library to simplify your life (it wraps the REST API), it has built-in support for client-side pages:
const sp = spfi(...);
// simplest add a page example
const page = await sp.web.addClientsidePage("mypage1");
https://pnp.github.io/pnpjs/sp/webs/#client-side-pages

Related

are there any web application designers like Appian/Salesforece?

So i want to develop a simple web application, which will basically be a basic form which on submission will allow to make an external api request. So are there any application designers that can allow to do that with minimalistic code. Appian for example has an interface/application designer that lets you drag and drop a UI interface and build a workflow, make api calls externally or to a database. So like that are there any other apps that allow to do something similar (make api calls/build ui easily/store in databse)? Any other suggestions are also welcome!
It heavily depends on the API as well as the kind of task you´re trying to achieve.
Here´s just a few examples and considerations. (All the below supposes that we´re talking about Web-Based APIs).
If the API requires authentication of some sort and the user authenticates himself: A simple HTTP file with JavaScript to send the request will do the job
If the API requires authentication but you authenticate for all the users: You will need a backend application that does the API request since you need something secure where you can put your Auth-Details for the API. Classic PHP or NodeJS in combination with a served HTTP file for the form itself would work without any JavaScript (depends on the API definitions)
If the API does not require authentication maybe a simple HTML form would work
If you want to write to a database you can have a look at something like https://directus.io/. They allow building a database with a UI and they automatically generate a Web-API which you can then feed by your forms. If the end-user is known to you Directus actually allows users to log in and fill the database with forms that you can visually design but this is rather for employees entering data into an internal database than customers submitting their contact data to you
From my personal experience, all the UI-Tools that promise to integrate with REST APIs make it really hard to do so since every API is different and there is no real standard for them.

Get content of page type in Kentico10 via Rest service

I am trying to retrieve data of page type via rest service in Kentico 10.
What should be format of base URL for sending Post request and for checking content on browser?
If you want to retrieve content you have to use GET (not POST). POST is for creating resources, PUT is for updating.
From the documentation:
The base URL of the Kentico REST service is /rest.
For example, if your site is running at http://localhost/Kentico, use
http://localhost/Kentico/rest as the base URL of the service.
This is how you retrieve all documents with all their coupled data:
http://localhost/Kentico/rest/content/currentsite/en-us/all/?coupleddata=true
Again, see the documentation for all the examples.
Try something like this:
/content/currentsite/<culture>/all/?classnames=<class code name>
Here you can find all the details on getting content/data via Kentico rest service.

Kentico based content in pardot

I have some CTAs based on a custom page type. I'm wondering if there is a way to get a json object so i can consume that in some JS on a pardot landing page i'm building out?
I'd like to avoid cutting and pasting the rendered HTML as I know these will change.
Are you aware of our REST services?
https://docs.kentico.com/k10/integrating-3rd-party-systems/kentico-rest-service/getting-data-using-rest/examples-of-data-retrieved-via-the-rest-service#ExamplesofdataretrievedviatheRESTservice-JSON
On the other hand, if REST is overkill for you you can take advantage of the Custom Response web part and return just the JSON you need or possibly this custom web part:
http://devnet.kentico.com/articles/custom-response-repeater

Google apps script in HTML

Is it possible to use google apps script in my HTML? I want to be able to write to a spreadsheet from a form in purely Javascript from an external framework such as Node.js.
https://developers.google.com/apps-script/
Google Apps Script's syntax is Javascript, however it is a unique server-side framework that does not behave as a library to applications outside of the Apps Script servers. (No, you won't be able to use Google Apps Script in your node.js app.)
However, that doesn't mean that your node.js app (or any other app on the web) can't interact with your spreadsheet. For instance, your app could authenticate as you using the OAuth API, then access the spreadsheet through the Google Drive API. For an example of this, see Accessing Google Spreadsheets from Node.js
Alternatively, you could roll your own spreadsheet API in Google Apps Script, to support read / write of your sheet via HTTP requests from your node.js app. There are plenty of examples of that, for example Insert new rows into Google Spreadsheet via cURL/PHP - HOW?.
Sure you can. You can use HtmlService to create your web form, then send the submission data to your Spreadsheet with server functions.
Nowadays you could use the Google Apps Script API to call your Google Apps Script code from other platforms like Node.js, actually the official docs include a quickstart for Node.js.
You can you use HtmlService, but maybe can be helpfull to read the Google Hosted Libraries https://developers.google.com/speed/libraries/
To use a Javascrtip library inside GAS, I recommend JQuery.
But Maybe, you can use Node.js inside your external website and make a AJAX Request (get or post) to a GAS and return from GAS this:
ContentService.createTextOutput(e.parameter.callback + "("+Utilities.jsonStringify(JSONDATA)+")").setMimeType(ContentService.MimeType.JSON);
After that, process it inside your AJAX request...
Mogsad is right that you might be better of with Google Drive API to interact with your Spreadsheet!
...But depending on your exact need you might have some possible interaction between external service and google apps scrip using Content service Google Dev link.
Content Service can send back several information upon GET request (ATOM, CSV, ICAL, JAVASCRIPT, JSON, RSS, TEXT, VCARD, XML). By playing around with url parameters you can get information out and in a spreadsheet, send an email, trigger some action etc!.
But that is far from a real external library and direct interaction with server side functions!

search engines index html5 web application with nodejs backend

I'm building an html5 web application with knockoutjs + backend rest service in nodejs (custom rest api, I'm not using express and i deliver only json data - no html).
The application is working fine like it is, but I need to get indexed by google.
I populate content using ajax requests and now i need to find a solution to make those pages "visible" for search engines.
Is there any true elegant solution for this? I don't want to make another backend service(website - expressjs or php etc)
Please advice :|
Google specifies a way for your site to provide "HTML snapshots" of ajax-loaded content. Not sure how well this works or if other search engines support it.
https://developers.google.com/webmasters/ajax-crawling/docs/getting-started

Resources