Posts

Showing posts with the label REST

Get user information SharePoint using REST Api

Hi, While working on a requirement, I encountered a scenario where I need to show welcome pop up to the first time users. First time user, SharePoint does not provide any api or any solution which gives information about users who logged on first time on your web site. I have documented the whole solution on some other post( Add welcome pop up for first time users of your site using AngularJs Material ) But this post I only want to scope it to retrieve information of logged on user. Information mean current user's accountId, First name, Last name, Email and other required details. I am only talking about client side code here i.e. using REST api or SP default APIs. Below are the various ways to get the property of current user who is logged on to SP site. There are many ways to achieve this requirement but I prefer to use SP.UserProfiles.PeopleManager Api to get it. It gives us vast option to retrieve any user information. Here are some details of getting various details: Ge...

Add welcome pop up for first time users of your site using AngularJs Material

Image
Hi Guys, We really do only have one chance for putting a first impression for end users on our website. User's will never land back to your website if there is nothing interesting found on web site. Same logic works for SharePoint sites too. When a visitor lands on your site for the first time (and maybe the last), how you welcome them will have a big impact. This can be accomplished with pop-up boxes, fullscreen welcome mats, live chat invitations, and more. This post is all about a welcome popup on SharePoint site. In brief, I try my best to provide very easy solution of showing welcome pop up. Requirement:  One of my recent project client asked to show a welcome message. Server side webarts are not promoted by out clients because our site was built in SP online. It sounds very easy but complication added by showing this pop up only once per user. Solution : As a solution, i suggested to achieve this using Content editor web part. Just place some quick JS code on the land...

Upload a file in SharePoint using REST and c# console application

Image
Hi, In my last post , I have explained how to create a sub site using REST from and Console application. In this blog  will explain how we can upload a file, which is located in file system, will be uploaded to sharepoint Document library. So if I brief about requirement here: Need to upload a file to already created SharePoint site. Use REST(not even CSOM) will be used in order to create. API call will be send from some other machine(not SharePoint machine) which is in same domain and can access the SharePoint site. Follow the given steps to achieve the same: 1) Create a simple console application with c# selected language. 2) Next is to install the Newtonsoft.Json. Navigate to Visual studio menu: "View" > "Other Windows" > "Package Manager Console" and Then type the following: "Install-Package Newtonsoft.Json" 3) Now install RestSharp using the package manager. Type the following: "Install-Package RestSharp" 4) Now open th...

Get SharePoint search results using REST ajax call from Html

Image
Hi, We all aware the SharePoint exposed REST Api in order to perform various action at client side. There are some other ways also which a developer can adopt instead of REST(like CSOM) but that requires again client context. So it is recommenced that if we are using SharePoint Apps then use CSOM to get and update the data. Where as REST can be used in apps as well as some external applications. This blog is intended to show how user can utilize the REST api and get the SharePoint Search results. There are few pre-requisites or conditions which must be fulfilled before proceeding further. The machine where this code will be executed must have access to sharepoint site which means machine must be either in same domain or cross domain accessibility is there. Search must be configured at SharePoint server. Data must be properly crawled and you must get some results when searched for some keyword. Steps: 1) Open the Explorer or any desired location and create a text file with ant des...

Create Sub Site in SharePoint using REST and c# console application

Image
Hi, Recently, I got an requirement to create a SharePoint sub site from the some .Net application which is hosted somewhere hosted outside the SharePoint environment. It is provided that the .Net application can be added in same domain. So if I brief about requirement here: Need to create a sub site in SharePoint site collection based on some default template(later on custom template) Use REST(not even CSOM) will be used in order to create. API call will be send from some other machine(not SharePoint machine) which is in same domain and can access the SharePoint site. There are few challenges which I faces if we try to work with such kind of requirements. The authentication tokens and RequestDigest data are the crucial things to retrieve. I have explored some way to execute REST API and create a sub site without navigating to SharePoint site. Follow the given steps to achieve the same: 1) Create a simple console application with c# selected language. 2) Next is to install the New...

SharePoint get followed sites using REST Api

Image
Recently I was tasked with a project requirement that the user should be able to see list of content he/she followed. To me this sounds much like using the following feature of SharePoint 2013 which allows you to follow documents, sites, people and tags. Also, we don’t want the user to navigate to his/her mySite and have a look on to the content followed. We can use the SharePoint 2013 Representational State Transfer (REST) service to do the same tasks you can do when you use the .NetCSOM, JSOM. Here I explain how to retrieve the site name and URL followed by the current user in SharePoint 2013 using a client object model (REST API and JavaScript) and displaying it in the SharePoint page. 1. Create a new page and a Content Editor Webpart (CEWP). 2. Edit the web part that was added to the page. 3. Upload your text file script into the site assests and copy the path of the text file and paste it into the Content link in CEWP. 4. Output Code The following example shows how to retrieve a...