Skip to content

Instantly share code, notes, and snippets.

View gautamdsheth's full-sized avatar
:shipit:
Shipping

Gautam Sheth gautamdsheth

:shipit:
Shipping
View GitHub Profile
@JustinGrote
JustinGrote / ModuleFast.ps1
Last active July 24, 2023 16:26
Bootstrap Script for a High Performance Module Installer
using namespace System.Net.Http
#requires -version 7.2
# This is the bootstrap script for Modules
[CmdletBinding(PositionalBinding = $false)]
param (
#Specify a specific release to use, otherwise 'latest' is used
[string]$Release = 'latest',
#Specify the user
[string]$User = 'JustinGrote',
#Specify the repo

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.

public static class AuthCheck
{
// This Function will return OK if the user is authenticated
[FunctionName("AuthCheck")]
public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")]HttpRequestMessage request, TraceWriter log)
{
var response = request.CreateResponse(HttpStatusCode.OK);
Cors.Enable(request, response);
@vgrem
vgrem / sp.rest.search.js
Created February 23, 2015 12:34
Demonstrates how to query all search results using SharePoint 2013 Search REST API
function search(webUrl,queryText,rowLimit,startRow,allResults)
{
var allResults = allResults || [];
var url = webUrl + "/_api/search/query?querytext='" + queryText + "'&rowlimit=" + rowLimit + "'&startrow=" + startRow;
return $.getJSON(url).then(function(data) {
var relevantResults = data.PrimaryQueryResult.RelevantResults;
allResults = allResults.concat(relevantResults.Table.Rows);
if (relevantResults.TotalRows > startRow + relevantResults.RowCount) {
return search(webUrl,queryText,rowLimit,startRow+relevantResults.RowCount,allResults);
}
$Url = $(Read-Host -Prompt "Enter site url:")
$web = Get-SPWeb $Url
$web.AllowUnsafeUpdates=$true
function Add-WebPartToPage($pageUrl, $webpartzone,$index,$fileName)
{
$webPartGallery = $web.Lists["Web Part Gallery"]
Write-Host "Searching webpart $fileName in web part gallery" -ForegroundColor Yellow
if($webPartGallery -eq $null)