Monday, June 17, 2019

MakePostRequest using HTTPCLIENT


JObject MakePostRequest(Dictionary<string,string> dict, string url )
        {
            try
            {
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
                var body = new StringContent(JsonConvert.SerializeObject(dict), Encoding.UTF8, "application/json");
                var response = client.PostAsync(url, body).GetAwaiter().GetResult();
                var responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                return JObject.Parse(responseString);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error : " + e.ToString());
            }
            return JObject.Parse("{}");

        }

Get All Tenant Site Designs and Save last ID + SharePoint Online

           

/*Get All site designs and noting recent ID */


var customeSiteDesignID = new System.Guid();
using (var tenantContext = new ClientContext(tenentWebUrl))            {
                tenantContext.Credentials = new SharePointOnlineCredentials(uName, securePassword);
                tenantContext.RequestTimeout = Timeout.Infinite;
                //get the tenant object
                Tenant tenant = new Tenant(tenantContext);
                //customeSiteDesignID = tenant.GetSiteDesign(tenantContext, customeSiteDesignID);

                var tenantdesigns = tenant.GetSiteDesigns();
                tenantContext.Load(tenantdesigns);
                tenant.RefreshLoad();

                /*loop All site designs & get oSiteDesign ID -  */
                try
                {
                    tenantContext.ExecuteQuery();
                    foreach (TenantSiteDesign oSiteDesign in tenantdesigns)
                    {
                        customeSiteDesignID = oSiteDesign.Id;
                    }
                }
                catch (Exception ex)
                {
                    log.Info("Error Occured in Getting Site Designs - " + ex.Message);
                }

}




Reference Link :

https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/mt846005(v%3doffice.15)


https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/mt846003(v=office.15)



Steps to Delete sites collections on SharePoint Online using Powershell script by importing CSV file


Steps to Delete sites collections using Powershell script by importing CSV file

$cred = Get-Credential
Connect-SPOService $adminSiteUrl -Credential $cred

$filepath="C:\GK\PowerShell Scripts\Deletion of Site Collections in CSV\Updated Gidc sites.csv"
$CSVData = Import-CSV -path $filepath
$SiteUrl="https://tenant.sharepoint.com/sites/TestSiteUsingAF";

Remove only one site
Remove-SPOSite -Identity $SiteUrl -NoWait
Remove-SPOSite -Identity  $SiteUrl -confirm:$false

Remove multiple sites which are listed CSV
foreach($row in $CSVData)
 {
 write-host "Deleteing Site " + $row.Url
 Remove-SPOSite -Identity $row.Url -confirm:$false
 }

Below command will get all site collections under Bin folder
Get-SPODeletedSite

Update or edit status filed in JIRA issue

the status field is a special case and can't be updated directly, which is the second problem here. Changing a status in Jira is called ...