Posts

Showing posts from February, 2024

SharePoint Search Using REST From JavaScript

Image
    Introduction SharePoint 2013 provides a very powerful endpoint, which you can use to retrieve search result and query suggestion. The first thing which we have seen is the available search endpoints Endpoint http://[host]/[site]/_api/search/query http://[host]/[site]/_api/search/postquery http://[host]/[site]/_api/search/suggest  The simplest way to run a query against REST API is to pass a keyword query. There are two basic ways to run searches, where one is by sending the search parameters through the RESTful URL and the other by sending them through the query or suggest endpoints. The querytext can be any legal keyword query language construction, including managed properties and operators. So far we’ve just looked at executing a basic query, where the query text is specified. Here are a couple of other common operations, which you might want to do. Operation Sample REST URL Specify the maximum number of record to return /_api/search/query?querytext='search term'...

spfx insert and update using sharepoint rest api

Image
  Insert into into sharepoint To insert an item into a SharePoint list using SharePoint Framework (SPFx) without a framework, you can use the SharePoint REST API. Here's a simple example of how you can achieve this in an SPFx web part: 1. Open your SPFx project in your preferred code editor. 2. In your web part code, you can make use of the SharePoint REST API to add an item to a list. Below is an example using the SPHttpClient : typescript Copy code import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base' ; import { sp } from '@pnp/sp' ; import { IMyWebPartProps } from './IMyWebPartProps' ; export default class MyWebPart extends BaseClientSideWebPart < IMyWebPartProps > { public render (): void { // Your web part rendering code } protected async onInit (): Promise < void > { // Ensure the SharePoint PnP JS is initialized sp. setup ({ spfxContext : this . context }); // Add an item...