Skip to content

Instantly share code, notes, and snippets.

Moving Files with SharePoint Online REST APIs in Microsoft Flow

About

This is an overview of how to move files with Microsoft Flow using the SharePoint - Send an HTTP request to SharePoint action and SharePoint Online REST APIs.

These SharePoint Online REST APIs can be used outside of Flow, but you will need to handle authentication and provide an X-RequestDigest header with any POST requests (as with any SP REST POST request).

In the case of Flow's SharePoint - Send an HTTP request to SharePoint action, authentication is handled for you and you do not need to provide the X-RequestDigest header.

Retrieving list item changes with the SharePoint Online Folder.GetListItemChanges REST API in Microsoft Flow

About

This post demonstrates how to retrieve SharePoint list item changes in Microsoft Flow using the SharePoint - Send an HTTP request to SharePoint action and the SharePoint Online Folder.GetListItemChanges REST API.

Why

This is something I started looking at after reading this set of tweets by John Liu:

Cross-site collection file copy with SharePoint Online REST APIs in Microsoft Flow

About

This is a follow up to my previous post: Moving Files with SharePoint Online REST APIs in Microsoft Flow, which explains how to move/copy files with Microsoft Flow using the SharePoint - Send an HTTP request to SharePoint action and the SharePoint Online SP.MoveCopyUtil REST API.

This post demonstrates using a similar approach, but using the CreateCopyJobs and GetCopyJobProgress APIs to copy files from one site collection to another.

I suggest reading the previous post first for context if you haven't already.

@zplume
zplume / Collectable.cs
Last active July 19, 2023 04:30
Example of polymorphic serialisation with JsonUtility
using UnityEngine;
using System;
[Serializable]
public class Collectable : PolymorphicObject
{
public string Name;
}
@zplume
zplume / GetSharePointPermissionLevels.js
Last active July 7, 2023 14:31
Get an array of Permission Levels (Role Definitions) for the current site using REST
// This script returns an array of Role Definition objects, containing the Permission Levels for the site
// See http://msdn.microsoft.com/en-us/library/office/jj244931(v=office.15).aspx for examples of how to use the
// SP.PermissionKind object to assign permissions to a Role Definition
// replacement function for console.log(), which avoids 'undefined' exception in IE 8
window.LogMsg = function (msg) {
if (window.console) {
console.log(msg);
}
@zplume
zplume / ShareDataBetweenWebparts.js
Last active June 30, 2023 15:06
Pattern to share data between SPFx webparts without using global variables, cookies or web storage
var SharedData = (function () {
function SharedData() {
}
SharedData.prototype.loadData = function () {
console.log("Loading data (should only be called once)");
SharedData.loadingData = true;
// simulate AJAX call to retrieve data
return SharedData.loadingPromise = new Promise(function (resolve, reject) {
setTimeout(function () {
SharedData.loadedData = true;
const queryStrings = window.location.search.substring(1).split("&").reduce((output, item, index) => {
if(item === "")
return output;
const keyValue = item.split("=");
output[decodeURIComponent(keyValue[0])] = keyValue[1] !== undefined ?
decodeURIComponent(keyValue[1]) :
true; // return true for query strings with no value
@zplume
zplume / LS.SP.JSOM.js
Last active June 30, 2023 15:04
SharePoint 2013 REST / JSOM / Utility functions (work in progress)
(function() {
var nsName = "LS"; // root namespace name
var ns = window[nsName]; // root namespace alias
var utils = ns.Utils; // utils alias
ns.SP = ns.SP || {};
ns.SP.JSOM = {
Data: {
Sites: {} // cache for Taxonomy terms JSON
},
@zplume
zplume / Update-Flows.ps1
Last active June 29, 2023 07:35
PowerShell script to update multiple Flows that have been exported from one environment for deployment to another environment. The script will unzip a set of Flow zip files from a source directory into a temp folder, replace source values with destination values, then save updated zip files into a destination directory.
param(
[Parameter(Mandatory = $true)]
[string]$SourceEnv,
[Parameter(Mandatory = $true)]
[string]$DestinationEnv
)
$ErrorActionPreference = "Stop"
# Note: these values could be loaded from elsewhere, e.g. CSV/XML (or dynamically if you want to get fancy)
@zplume
zplume / FormatO365AuditLogs.ps1
Created June 9, 2017 09:29
Converts the bizarre JSON-in-CSV format of O365 audit logs to a more useful CSV of the JSON data. Run the script from the directory containing the $inputFile or specify a full path rather than just a file name.
$inputFile = "AuditLog_2017-05-18_2017-05-27.csv"
$outputFile = "AuditLogData.csv"
Import-Csv -Path $inputFile | ForEach-Object { $_.AuditData } | ConvertFrom-Json | Export-Csv -Path $outputFile -NoTypeInformation