Default All Documents view in a SharePoint document library got corrupted

Some how the default view (All Documents – …/Forms/AllItems.aspx) in a document library in SharePoint Online got corrupted and now shows gibberish:

“…PK!A�.fT(Content_Types).xml �(����n�0E����� �tQUUH},�HM?����/����;@��(�I6H0s�=xF��V� |���d� H�(!M����(�H��LY9�B ����h�uT���E�����YȬ���z�”���:�X �~0x�ܚ&��� ��l�b��� ɷ��$�Mc���+��@�j<�p�a�)�Y�:)q@��2T�=a!)�Æ������}���R@2e>�3�)tm����Fev���- ɡ�Wn�(!�w�*k+�I����q� ���폇Qp ��s/��W��c�R`����”…

As a temporary solution I created a new default view, but need to restore the old one at AllItems.aspx as users have links to it…

What is the best way to restore or repair the view?
Shall I delete the view and recreate new with the same AllItems.aspx address?

Thank you in advance.

Regards,

Deleting all document versions but the current from a SharePoint document library using PowerShell

I have a SharePoint document library with a large number of documents and versions. My task is to create a PowerShell script to delete all versions but the current for each document.

When I tried to delete the versions within my iteration, I got an error saying that the “collection was modified”. Fair enough, I can’t change the collection I’m looping through.

So instead I added the versions to be deleted in an array to be processed later outside the loop. But that didn’t work eighter, I get “Exception calling Delete with 0 argument(s): Object reference not set to an instance of an object.”

I have reviewed all similar Q&As for this issue on this site, but no answer is spot on. Can anyone give a hint on what is going on here? Thanks so much for any help.

asnp *sh*
$site = new-object Microsoft.SharePoint.SPSite("http://somesite")
$web = $site.RootWeb
$list = $web.Lists("Dokument")
cls
$versionsToDelete = @()

foreach ($listItem in $list.Items)
{
    foreach ($ver in $listItem.Versions)  
    {
        if (!$ver.IsCurrentVersion)
        {
            $versionsToDelete += $listItem.Versions.GetVersionFromLabel($ver.VersionLabel)
        }
    }
}

for($i=0;$i -lt $versionsToDelete.Count;$i++)
{
    write-host "Trying to delete" $versionsToDelete.VersionLabel($i)
    $versionsToDelete($i).Delete()
}

$web.Dispose()
$site.Dispose()

Can I migrate a library from SP 2016 down to a different SP 2013 farm?

Can I migrate a SP library (of documents) from SharePoint 2016 down to a new SharePoint 2013 farm/ site?

We just want this content and folder structure on the SP 2013 farm (Not the entire site collection).

Is this possible?
Is it difficult?
Any advice?

sharepoint online – crud operation using bootstrap with pnp library

Check if the request has this problem.
enter image description here

You could know how to solve this problem here:

https://github.com/SharePoint/PnP-JS-Core/wiki/Using-sp-pnp-js-in-SharePoint-Framework

My test code for your reference:

import { Version } from '@microsoft/sp-core-library';
import {
  IPropertyPaneConfiguration,
  PropertyPaneTextField
} from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset';
import {Web } from 'sp-pnp-js'

import styles from './NoframeworkspfxWebPart.module.scss';
import * as strings from 'NoframeworkspfxWebPartStrings';
import { SPHttpClient, SPHttpClientResponse, SPHttpClientConfiguration,ISPHttpClientOptions } from '@microsoft/sp-http'; 
export interface INoframeworkspfxWebPartProps {
  description: string;
}
var moment:any = require('moment-timezone');
export default class NoframeworkspfxWebPart extends BaseClientSideWebPart <INoframeworkspfxWebPartProps> {

  
  public render(): void {
    //let cssURL = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css";
    //SPComponentLoader.loadCss(cssURL);
  
    this.domElement.innerHTML = `
    <div class="panel panel-info">
        <div class="panel-heading"><h3 class="panel-title"><strong>Sign In </strong></h3></div>
        <div class="panel-body">
            <div class="form-group">
              <div class="row" hidden>
                <div class="col-md-12">
                  <label for="empID" class="control-label">Enter Employee ID</label>
                </div>
                <div class="col-sm-8">
                  <input type="text" class="form-control" id="empID" placeholder="Enter ID">
                </div>
                <div class="col-sm-2">
                  <button type="submit" class="btn btn-primary" id="btnRead">Read Details</button>
                </div>
              </div>
            </div>
            <div class="form-group">
                <label for="empName">Employee Name</label>
                <input type="text" class="form-control" id="empName" placeholder="Enter email">
            </div>
            <div class="form-group">
                <label for="gender">Gender</label>
                <input type="text" class="form-control" id="empGender" placeholder="Password">
            </div>
            <div class="form-group">
                <label for="empDesignation">Designation</label>
                <input type="text" class="form-control" id="empDesignation" placeholder="Enter email">
            </div>
            <div class="form-group">
                <label for="empDepartment">Department</label>
                <input type="text" class="form-control" id="empDepartment" placeholder="Password">
            </div>
            <div class="form-group">
                <label for="empLocation">Location</label>
                <input type="text" class="form-control" id="empLocation" placeholder="Enter email">
            </div>
            <div class="form-group">
                <label for="empEmail">Email</label>
                <input type="text" class="form-control" id="empEmail" placeholder="Password">
            </div>
            <button type="submit" id="btnSubmit" class="btn btn-sm btn-primary">Submit</button>
            
            <div id="divStatus"></div>
            <div id="spListData"></div>
        </div>
    </div>`;
    this._bindEvents();
  }

  private _bindEvents(): void {
    this.domElement.querySelector('#btnSubmit').addEventListener('click', () => { this.addListItem(); });
  }

  private addListItem(): void {
    var employeeName = document.getElementById("empName")("value");
    var employeeGender = document.getElementById("empGender")("value");
    var employeeDesignation = document.getElementById("empDesignation")("value");
    var employeeDepartment = document.getElementById("empDepartment")("value");
    var employeeLocation = document.getElementById("empLocation")("value");
    var employeeEmail = document.getElementById("empEmail")("value");
    let web = new Web(this.context.pageContext.web.absoluteUrl);
    web.lists.getByTitle("test_test").items.add({
      Title: employeeName,
      // Gender: employeeGender,
      // Designation: employeeDesignation,
      // Department: employeeDepartment,
      // Location: employeeLocation,
      // Email: employeeEmail
    
    }).then(r => {

      alert("success");
    }); 
  }
  protected get dataVersion(): Version {
  return Version.parse('1.0');
}




  protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
  return {
    pages: (
      {
        header: {
          description: strings.PropertyPaneDescription
        },
        groups: (
          {
            groupName: strings.BasicGroupName,
            groupFields: (
              PropertyPaneTextField('description', {
                label: strings.DescriptionFieldLabel
              })
            )
          }
        )
      }
    )
  };
}
}

Test result:
enter image description here

Adding “Site Page” Content type in Pages library inside SharePoint Online modern Site does not work

I am tried to enable modern page in “Pages” library by adding the “Site Page” content type inside “Pages” Library in modern SharePoint online site.
After adding the content type , while creating the modern page by selecting the “Site Page” content type does not work.

Kindly help in this case.

Thanks,
Kailash

2013 – How to get data from videos in asset library?

Videos in an asset library are “hidden” in folders in an otherwise ordinary document library. The name you see in the library is the name of the folder, not the video. As you have probably already found the SharePoint library REST APIs, you just need to add the folder to the path.

See if this helps to find those details: https://techtrainingnotes.blogspot.com/2015/05/sharepoint-2013-asset-library-secrets.html

document library – Online – Get thumbnail in search results

I’m using SharePoint Online and I’ve a CEWP where I call SharePoint search API.

In this call I’m using a query template because I want to retrieve only .mp4 files. In my document library I’ve also a “Thumbnail” column (picture) which automatically shows thumbnail of the video.

I’m trying to get this column in my search results, so I can show thumbnails in my CEWP. I’ve also take a look to the OOB SharePoint search results and I can see that the thumbnail of the video is correctly shown.

How can I have the Thumbnail column in my search result dataset?

library – Python decorator for token for REST API client

My goal is to provide a decorator named @with_access_token that can be added to API calls that need an access token – so that the method’s caller doesn’t have to worry about getting/refreshing it. Here is how I have separated my implementation. Is this right? I find the cyclic dependency between decorators.py and the api_client.py incorrect. Please have a look at below implementations.

auth_helper.py (For oauth, and token storage)

class app_auth:
    host = None
    client = None
    secret = None
    access_token = None
    user = None
    password = None
    token_expiry = 0

    def __init__(self, host, client, secret, user, password):
        self.host = host
        self.client = client
        self.secret = secret
        self.user = user
        self.password = password

        self.access_token = self.get_access_token()

    def get_access_token(self):
        if time.time() > self.token_expiry:
            # auth call
            self.access_token = response.json()('access_token')

api_client.py : a specialized API client need access token for each API call

from decorators import *
class api_client:
    app_auth = None
    def __init__(self):
        self.app_auth = app_auth(params)

    def update_token(self):
        self.app_auth.get_access_token()

    @with_access_token
    def create_foo():
        header = {"Authoriztaion" : "Bearer " + app_auth.access_token}
        # REST API call
        # code here

    #many such decorated functions

I feel something is not right here as I could just invoke the update_token from each method instead of adding @with_access_token

**decorators.py provide the decorator wrapper

def with_access_token():
    def wrapper(api_client, *args, **kwargs):
        api_client.update_token()
        return func(api_client, *args, **kwargs)

Please note I am requesting review on the decomposition, not on syntax/naming correctness, and/or style

recommended Office 365/SharePoint rest api/Graph api js library – for custom solution

I’m after a reliable rest api js library i can use to build a custom solution using sharepoint online backend
I know of this

the pnp js library but are there other recommenced libraries that is avaialabe?

Any resources would be appreciated and thanks in advance

api – library for validating bitcoin private and public keys

No sane application should EVER attempt to validate a private key by attempting to pass it to an external API. That’s a ridiculously easy way to lose all your funds if the API operator is malicious, compromised, or someone is eavesdropping on your communication with said API.

You should do this yourself, preferably using a well tested, community supported, open source library for your choice of language – most major languages have such libraries.

If this is too much work, you should reconsider building something like this. Do not compromise on safety, especially if you intend for other people to trust this code with their funds.