Catégorie : Programmation

Connect to SharePoint Online from NodeJS using an impersonate (application) Bearer Token

(duplicate of this StackOverflow answer) Start a new project In a new folder, type npm init to start a new project. Make sure to use a Node >= v14 (I use Node v18 – and Volta can be useful to manage several versions of Node for Windows) Install some dependencies: npm install axios @azure/msal-node uuid […]

Search and restore an item from a SharePoint Online Recycle Bin

It might be difficult to search for an item in a SharePoint recycle bin. I was using the end point _api/site/RecycleBin as a Site Collection Administrator, but in some cases it returns an error « The attempted operation is prohibited because it exceeds the list view threshold. ». The solution is to use another end point _api/site/getrecyclebinitems […]

Calculating HMAC SHA-1 in the Browser

If you’re looking for the equivalent of hash_hmac(‘sha1’, ‘string’, ‘secret’); in JavaScript, then here you go: async function hmac_sha1 (str, secret) { // see https://stackoverflow.com/a/47332317/1134119 let enc = new TextEncoder(« utf-8 »); let key = await window.crypto.subtle.importKey( « raw », // raw format of the key – should be Uint8Array enc.encode(secret), { // algorithm details name: « HMAC », hash: {name: […]

Connect to SharePoint Online using an app clientId and clientSecret

Get `clientId` and `clientSecret` (source) You’ll need credentials: `clientId` – required string, client id obtained when registering the addin `clientSecret` – required string, client secret obtained when registering the addin `realm` – your SharePoint Online tenant id. The easiest way to find tenant is to open SharePoint Online site collection, click Site Settings → Site […]

spfx error: No development certificate found. Generate a new certificate manually, or set the `canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`

When using the command gulp serve, you could receive the below error: No development certificate found. Generate a new certificate manually, or set the `canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync` To resolve, you can type gulp trust-dev-cert.

SharePoint 2013 Search REST API options

Finding the documentation for the Search REST API of Sharepoint is difficult…. There is a very old blog post that I’m going to replicate here to give more visibility:   Location of the Search Rest service The Search REST service is located at the following URI: http://host/site/_api/search   The Search REST API The Search REST […]

SP.Utilities.Utility.SendEmail returns « The e-mail message cannot be sent. Make sure the e-mail has a valid recipient. »

With Sharepoint you can use SP.Utilities.Utility.SendEmail to send email in JavaScript, however you could receive the below error: « The e-mail message cannot be sent. Make sure the e-mail has a valid recipient. » After searching the web, I found the solution: instead of using an email address for the recipients you have to use the userDomain […]

Create a self-signed certificate for localhost testing with IE11 and Webpack

Sources: https://stackoverflow.com/questions/44988163/create-self-signed-certificate-for-testing-localhost-and-have-it-accepted-by-the http://woshub.com/how-to-create-self-signed-certificate-with-powershell/ https://stackoverflow.com/questions/4691699/how-to-convert-crt-to-pem/4691749#4691749 https://webpack.js.org/configuration/dev-server/#devserver-https If you develop with Webpack under Windows and you want to open your localhost server in HTTPS with IE11 you may receive a message like : « Content was blocked because it was not signed by a valid security certificate. » Below I explain the steps to make it work with IE11: […]