Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Vadim Gremyachev vgrem

🏠
Working from home
View GitHub Profile
@vgrem
vgrem / setLike.js
Created Dec 26, 2016
Demonstrates how to like/unlike resource via SharePoint REST API
View setLike.js
var Reputation = Reputation || {};
Reputation = (function () {
function executeJson(options) {
var headers = options.headers || {};
headers["Accept"] = "application/json;odata=verbose";
if (options.method == "POST") {
headers["X-RequestDigest"] = $("#__REQUESTDIGEST").val();
}
@vgrem
vgrem / renameFolder.js
Created Nov 5, 2014
Rename folder using SharePoint REST Interface
View renameFolder.js
executor.executeAsync({
url: "<app web url>/_api/SP.AppContextSite(@target)/web
/getfolderbyserverrelativeurl('/Shared Documents/Orders')
?@target='<host web url>'",
method: "POST",
body: "{ '__metadata':{ 'type': 'SP.Folder' }, 'Name':'Archive Orders' }",
headers: {
"content-type": "application/json; odata=verbose",
"X-HTTP-Method": "MERGE"
},
@vgrem
vgrem / Get-SPOAccessToken.ps1
Created Jan 25, 2015
Obtain the access token from a Microsoft Azure Access Control Service (ACS) account that is associated with the customer's Microsoft Office 365 tenancy
View Get-SPOAccessToken.ps1
<#
.Synopsis
Obtain an app-only access token from ACS.
.DESCRIPTION
Retrieves an app-only access token from ACS to call the specified principal
at the specified targetHost. The targetHost must be registered for target principal. If specified realm is
null, the "Realm" setting in web.config will be used instead
.EXAMPLE
Get-SPOAccessToken -Url "https://contoso.sharepoint.com/_api/web" -ClientId "" -ClientSecret ""
#>
@vgrem
vgrem / createNewDiscussionReply.js
Created Sep 12, 2016
Demonstrates how to create a message (reply) in Discussion Board via SharePoint REST API
View createNewDiscussionReply.js
function executeJson(options)
{
var headers = options.headers || {};
var method = options.method || "GET";
headers["Accept"] = "application/json;odata=verbose";
if(options.method == "POST") {
headers["X-RequestDigest"] = $("#__REQUESTDIGEST").val();
}
var ajaxOptions =
View MapExample.js
import React, { useEffect } from "react";
import { Map, GeoJSON, TileLayer } from "react-leaflet";
import leafletStream from "leaflet-geojson-stream";
function StreamGeoJsonLayer(props) {
const layerRef = React.useRef();
const { url } = props;
useEffect(() => {
const gj = layerRef.current.leafletElement;
leafletStream.ajax(url, gj).on("end", function () {
View data.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vgrem
vgrem / SPOUpload-Files.ps1
Last active Oct 2, 2020
Upload files into Document Library in SharePoint Online
View SPOUpload-Files.ps1
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Function Ensure-Folder()
{
Param(
[Parameter(Mandatory=$True)]
[Microsoft.SharePoint.Client.Web]$Web,
@vgrem
vgrem / SharePointClient.cs
Last active Sep 24, 2020
Generic Rest Client for SharePoint REST Inteface
View SharePointClient.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace SharePoint.Client
{
@vgrem
vgrem / Invoke-RestSPO.ps1
Last active Sep 18, 2020
SharePoint Online REST request
View Invoke-RestSPO.ps1
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
<#
.Synopsis
Sends an HTTP or HTTPS request to a SharePoint Online REST-compliant web service.
.DESCRIPTION
This function sends an HTTP or HTTPS request to a Representational State
Transfer (REST)-compliant ("RESTful") SharePoint Online web service.
.EXAMPLE