Tag Info

Hot answers tagged

5

The following example demonstrates how to determine whether current users belongs to the specified groups: getCurrentUserWithDetails() .done(function(data) { var groupNames = ['News Owners','Approvers']; //determine wether current user is a memeber of group(s) var userGroups = data.d.Groups.results; var foundGroups = ...


3

You could try the following endpoint: https://server/_api/Web/GetFolderByServerRelativeUrl(<folder url>)?$expand=Folders,Files It returns files and folders beneath folder at the specified url. JavaScript example The following example demonstrates how to retrieve files and folder beneath 2015 folder: var folderUrl = '/documents/2015'; var url = ...


3

_api/Web/Lists/GetByTitle('MyTasks')/Items?$expand=AssignedTo&$select=AssignedTo/FirstName,AssignedTo/LastName (Tested on 365) Note that you need to $select all the fields you need when using $expand like this.


3

As far as I know it is not supported to apply $filter or $select expression for the endpoint: http://<sitecollection>/<site>/_api/web/lists(listid)/getItems(query) To summarize: CAML and OData query could not be combined. From another hand, since expanding of User Fields is not supported in CSOM/REST i would suggest to construct your ...


2

This error occurs since filter expression could not be applied for File Collection resource. From another hand, StudyId field is a property of List Item resource and not a File. Having said that, you could utilize the following query to return File with StudyId set to 123456: ...


2

According to Working with folders and files with REST the following example demonstrates how to create a Folder: url: http://site url/_api/web/folders method: POST body: { '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': '/document library relative url/folder name'} Headers: Authorization: "Bearer " + accessToken X-RequestDigest: form ...


2

Cross domain calls are blocked by modern web browsers due to security concerns. To get round this you can use the SP.RequestExecutor.js script to relay messages to SharePoint from within the same domain. Example function getListItem(hostUrl,appWebUrl, listTitle,itemId,success,error) { var url = appWebUrl + ...


1

Add following to your REST query $select=FileLeafRef


1

A sharepoint app essentially exists in a domain. So you need to either use SP.RequestExecutor.js or use SP.AppContextSite This is the structure of the URL if using SP.AppContextSite var url = appwebUrl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('"+listName+"')/items?$select=Title,ID&@target='" + hostUrl + "'"; This is the general ...


1

This looks like a typical Same-Origin-Policy issue that may be solved configuring CORS on the remote server, and may be worked around proxying the communication between your server and the remote server: put some piece of software in your server that performs the real requests to the remote server. This way, all the calls from your browser will be to the ...


1

AAM was the answer. The starting point is this link


1

Look this sample from MSDN. Provider-hosted apps written in JavaScript must use the SP.RequestExecutor cross-domain library to send requests to a SharePoint domain. You can upload files up to 2 GB with the REST API. jQuery(document).ready(function () { // Check for FileReader API (HTML5) support. if (!window.FileReader) { alert('This ...


1

Its should be $select=Collaborators/Title&$expand=Collaborators Example your URL should like http://yoursite/_api/web/lists/GetByTitle('Employee Details')/items("1")?$select=ManagerName/Title,FirstName,LastName,Position,Phone,Fax,PreviousCompany,Reference,BirthDate,Relocate,EmailAddress&$expand=ManagerName


1

The following query demonstrates how to exclude system folders: https://site/_api/Web/GetFolderByServerRelativeUrl('<folder url>')/Folders?$filter=ListItemAllFields ne null&$expand=ListItemAllFields SP.Folder.listItemAllFields property is used to determine whether Folder is system or not since system folders are not associated with a List ...


1

That may be because the default address is the server name, and your code is run on the server itself. In that case, everything is fine. But if you use another domain name to target the server from the server itself, you may face the "loopback check" feature of Windows Server. You can test quickly by disabling this feature, like mentionned in method 2 of ...


1

You can get all of the documents and folders contained directly under a given subfolder in a document library: /_api/web/Lists/GetByTitle('DocLib')/GetItems(query=@v1)?$select=Title,File/Name&$expand=File&@v1={"ViewXml":"<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='FileDirRef' /><Value ...


1

It is not. The out of the box functionality has a single stack that throws any requests for that asset into the counter. You'd have to do some code to get what you're referring to either on server or client side.


1

Use the ViewsLifetime and ViewsRecent metadata returned from http://site/subsite/_api/search/query (such as http://site/subsite/_api/search/query?querytext='ContentTypeId:0x010100C568*'). No views is a null value. (in JSON the return looks like) 20: { __metadata: { type: "SP.KeyValue" }- Key: "ViewsLifeTime" Value: "246" ValueType: "Edm.Int64" }- 21: { ...


1

I assume you mean SharePoint 2013. In this case, of course, you can create lists, including document libraries via REST, as described here. For the document library you should use 101 as the BaseTemplate. url: http://site url/_api/web/lists method: POST body: { '__metadata': { 'type': 'SP.List' }, 'AllowContentTypes': true, 'BaseTemplate': 101, ...


1

How to create a Document library using SharePoint REST: url: http://site url/_api/web/lists method: POST body: { '__metadata': { 'type': 'SP.List' }, 'AllowContentTypes': true, 'BaseTemplate': 101, 'ContentTypesEnabled': true, 'Description': 'My Documents Library', 'Title': 'Documents' } Headers: Authorization: "Bearer " + accessToken ...


1

You could utilize Web.SiteUsers property to gets the all users that belong to the site collection. But since it returns all the users including system accounts, the following examples demonstrate how to return only real users. CSOM using (var ctx = GetContext(webUri,userName,password)) { var users = ctx.LoadQuery(ctx.Web.SiteUsers.Where(u => ...


1

Look into Vadim's answer here: Is it possible to create a Document Set using REST API Instead of using (which is at the bottom of the first code snippet): createFolder(webUrl,listName,folderName,'0x0120D520', success, error); Use: createFolder(webUrl,listName,folderName,'0x0120', success, error);


1

Two leads I guess. First, you may miss authorization Header, but it depends of your list security settings, like for example : headers: { ... "Authorization": "Bearer " + UserOrAppToken ... } But more likely, I usually also think ContentLength is mandatory : ... type: "POST", contentType: "application/json;odata=verbose", ...


1

I just changed around the success to grab it from the array instead: success: function(data) { var results = data.d.results; console.log(results[0].Id); } I am now able to grab that Id.


1

It looks like you expect the value of an element, based on ID, to be referable in a query, which doesn't make much sense, at least not to me. Instead you need to get the value from the input, and build the query. There are several ways to do this, here is one: var lawsonId = document.getElementById('LawsonID').value; var query = ...


1

Probably your version is SharePoint 2013 but without SP1 installed. If so, JSON Light is not supported. If so, you could change metadata format from: application/json;odata=minimalmetadata to: application/json;odata=verbose If your version is SharePoint 2013 SP1, then make sure multiple metadata formats for JSON is turned on.


1

There are now throttling limits for Office 365 REST APIs. See https://msdn.microsoft.com/en-us/library/office/dn889829.aspx Throttling can be triggered if you exceed 1 request per second continuously. You will receive a HTTP status code 429 ("Too many requests") if this happens. For your average app you are unlikely to trigger throttling. But for intensive ...


1

The following example demonstrates how to authenticate HttpClient in SharePoint Online: public class SPHttpClientHandler : HttpClientHandler { public SPHttpClientHandler(Uri webUri, string userName, string password) { CookieContainer = GetAuthCookies(webUri, userName, password); FormatType = FormatType.Json; } protected ...



Only top voted, non community-wiki answers of a minimum length are eligible