Showing posts with label rest endpoint. Show all posts
Showing posts with label rest endpoint. Show all posts

Thursday, 23 March 2017

Author(Created By) Managed Property having more than one user in Odata search results SharePoint 2013

Hi All,
 
In our project we faced an issue in search query. Our requirement is to show all the requests raised by the current user in a page. So Basically we need to use "Created By" field in Search Rest end point url. Initially we used the following Rest end point url to retrieve the requests.
 
<Site_URL>/_api/search/query?querytext='Author:"<Current User Login Name>"
 
Please Note that we have used the managed property "Author" as it is the internal name of "Created By". 
Later we got an issue that more than one user was able to see the same request . Logically "created by" will be only one user. The issue is because "Author" property has the user who created the item and also the user who last modified the item. So the item was visible for both creator and last modified user.
 
For this we found an other managed property AuthorOWSUSER which resolved our issue.
 
So the final rest end point url is
 
<Site_URL>/_api/search/query?querytext='AuthorOWSUSER:"<Current User Login Name>"

Thank You 
Happy Coding ☺

Friday, 25 December 2015

REST End point URLs - SharePoint 2013

Today I will be sharing the Service End point URLs for the SharePoint 2013. To access SharePoint resources using REST, construct a RESTful HTTP request, using the Open Data Protocol (OData) standard, which corresponds to the desired client object model.

Example :

List Name - Products

Columns - Title , Company , Products , Manager

In which Title , Company are Single Line of Text columns.
Company is a lookup column ( LookUp list - Company Names  and It is Looking up to the column Company name with Internal Name Title ) .
Manager is a people Picker Column.

Service call for accesssing the columns would be -

(Always use Internal names for the columns and Display names for the List)
https://halyardhealth.sharepoint.com/sites/SPDEV/_api/web/lists/getbytitle('Products')/items?$select=Title,Products,Company/Title,Manager/Title&$expand=Company,Manager

For Lookup and People picker colums we have to expand the column like above

For applying the filter on the above query -

https://halyardhealth.sharepoint.com/sites/SPDEV/_api/web/lists/getbytitle('Products')/items?$select=Title,Products,Company/Title,Manager/Title&$expand=Company,Manager&$filter=Products eq 'Product 1'

https://halyardhealth.sharepoint.com/sites/SPDEV/_api/web/lists/getbytitle('Products')/items?$select=Title,Products,Company/Title,Manager/Title&$expand=Company,Manager&$filter=Company/Title eq 'Company 1'

For applying multiple filters :

https://halyardhealth.sharepoint.com/sites/SPDEV/_api/web/lists/getbytitle('Products')/items?$select=Title,Products,Company/Title,Manager/Title&$expand=Company,Manager&$filter=((Products eq 'Product 1') and(Company/Title eq 'Company 1'))

From the next post onwards I will be providing the codes for CRUD operation on Sharepoint 2013 list using Rest api.

Happy Coding...