Skip to content

Instantly share code, notes, and snippets.

View vman's full-sized avatar
👨‍💻

Vardhaman Deshpande vman

👨‍💻
View GitHub Profile
@vman
vman / createsitecollection.cs
Last active March 13, 2024 08:16
Create Site Collection from CSOM
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using System;
using System.Security;
namespace CreateSiteCollections
{
class Program
{
static void Main(string[] args)
@vman
vman / UpdateListItemNometadata.js
Last active July 7, 2023 14:49
Update SharePoint List items without using the '__metadata' property (ListItemEntityTypeFullName)
$(function() {
'use strict';
var requestHeaders = {
'X-RequestDigest': $("#__REQUESTDIGEST").val(),
"accept": "application/json;odata=nometadata",
"content-type": "application/json;odata=nometadata",
"IF-MATCH": "*",
"X-HTTP-Method":"MERGE"
};
@vman
vman / Set.Single.UserProfileProperty.js
Last active July 7, 2023 14:46
SharePoint Online: Set Single Value User Profile property with REST API
(function ($) {
'use strict';
var requestHeaders = {
'X-RequestDigest': $("#__REQUESTDIGEST").val(),
"accept": "application/json; odata=nometadata",
"content-type": "application/json;odata=nometadata"
};
var userData = {
@vman
vman / spfxPOST.ts
Last active September 19, 2022 15:48
Making a POST request to SharePoint from an SPFx webpart
private _makePOSTRequest(): void {
const spOpts: ISPHttpClientOptions = {
body: `{ Title: 'Developer Workbench', BaseTemplate: 100 }`
};
this.context.spHttpClient.post(`${this.context.pageContext.web.absoluteUrl}/_api/web/lists`, SPHttpClient.configurations.v1, spOpts)
.then((response: SPHttpClientResponse) => {
// Access properties of the response object.
console.log(`Status code: ${response.status}`);
@vman
vman / GetTenantPropsCSOM.cs
Last active February 18, 2022 16:39
Get SharePoint Online Tenant Properties using CSOM
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core;
using System;
namespace TenantProps
{
class Program
{
static void Main(string[] args)
{
@vman
vman / CSOM.MFA.cs
Last active December 17, 2021 17:41
SharePoint Online: Using CSOM with an account configured with Multi-factor Authentication (MFA)
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core;
using System;
namespace CSOMDemo
{
class Program
{
static void Main(string[] args)
{
import * as React from 'react';
import styles from './HelloTeams.module.scss';
import { IHelloTeamsProps } from './IHelloTeamsProps';
import { useEffect, useState } from 'react';
const HelloTeams: React.FunctionComponent<IHelloTeamsProps> = (props: IHelloTeamsProps) => {
const [themeState, setThemeState] = useState<string>(props.teamsTheme || "default");
const [styleState, setStyleState] = useState<string>(styles.containerdefault);
using Microsoft.Bot.Builder;
using Microsoft.Bot.Connector;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Bot.Schema.Teams;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core;
using System;
namespace AppPermissionsDemo
{
class Program
{
static void Main(string[] args)
{
import * as React from 'react';
import { ServiceScope } from '@microsoft/sp-core-library';
import { withServiceScope } from '../common/withServiceScope';
import { MSGraphClientFactory, MSGraphClient } from '@microsoft/sp-http';
interface IHelloUserProps {
serviceScope: ServiceScope;
}
interface IHelloUserState {