Hot answers tagged

21 votes
Accepted

SharePoint 2013 REST api to update list item- Uncaught ReferenceError: etag is not defined

This error occurs since tag variable is not defined. About eTag When updating or deleting items within SharePoint lists via REST you must specify the Entity Tag (eTag) value that was returned ...
12 votes

SharePoint REST API call with more than 500 rows

Here is an example that demonstrates how to query all search results using SharePoint 2013 Search REST API: function search(webUrl,queryText,rowLimit,startRow,allResults) { var allResults = ...
11 votes
Accepted

Creating Folder using REST and JavaScript

What about using the Add method: If for example using SiteCollectionDocuments in a Site Collection 'url' : _spPageContextInfo.siteAbsoluteUrl + "/_api/Web/Folders/add('SiteCollectionDocuments/...
  • 720
10 votes

Use SharePoint 2013 "Working on it..." during ajax call

You need to call close() on object returned from showWaitScreenWithNoClose(). This works for me: var loading = SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15); loading.close();
  • 1,924
10 votes
Accepted

AJAX/Rest only returning 100 items instead of full list

The OData provider for the REST API is configured to limit the number of items in a response to 100. It protects against developers inadvertently making a request that returns large result sets. If ...
  • 11.9k
8 votes
Accepted

Is AJAX Built-in in SharePoint-Online ( SharePoint-Hosted Apps )?

Ajax has nothing to do with jQuery per se. https://en.wikipedia.org/wiki/Ajax_(programming) http://blog.garstasio.com/you-dont-need-jquery/ajax/ http://caniuse.com/#feat=xhr2 jQuery has a function ...
7 votes
Accepted

Use SharePoint 2013 "Working on it..." during ajax call

You call your method showWaitScreenWithNoClose using asyncronously with callback ExecuteOrDelayUntilScriptLoaded. If sp.js is not loaded, then closing event can fire before the wait dialog is showed. ...
  • 1,954
6 votes

Creating Folder using REST and JavaScript

Make sure the correct ServerRelativeUrl has been provided, the following formats could be specified: Server-relative URL: /<web url>/<list url>/<folder url> Site-relative URL: <...
5 votes
Accepted

AssignedTo Column multi users via REST-API

First of all you have to Allow multiple selections in AssignedTo column. To add/update multi valued Person or Group column, you have to specify the ID's of the Persons or Groups like var data = { ...
5 votes

How to get list items using Ajax and rest services

Here you can use any of the query but before that you must be clear with your own requirement. If you want to get data with specific parameter (like you want to filter your data) then you can use the ...
5 votes

Getting this error: An entry without a type name was found, but no expected type was specified

I think this occurs due to missing Type attribute in List Item entry. If you want to create list items using REST you will need to include the list item type. The list item type is a string ...
  • 260
5 votes

AJAX Pass variable to successhandler

function addList() { var something = "ABC"; getData(url).success(function(data) { successHandler(data, something); }); } function successHandler(data, something) { console....
  • 11.9k
5 votes

AJAX Pass variable to successhandler

Robs answer works, But you might as well move the whole function inside the addList scope (unless the function is called from other functions as well) The JavaScript .bind() method is the JS way of ...
4 votes

Getting this error: An entry without a type name was found, but no expected type was specified

When making a POST request, __metadata attribute isn't required if aren't passing the Accept:"application/json;odata=nometadata" header. If you are passing in a verbose header you would need to ...
4 votes
Accepted

update sharepoint list using jQuery and ajax

How to update List Item via SharePoint REST interface function updateJson(endpointUri,payload, success, error) { $.ajax({ url: endpointUri, type: "POST", data: ...
4 votes

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

First: To really troubleshoot the very generic "500 (Internal Server Error)" error, you'd need to get access to the server ULS logs, or attach a debugger to w3wp.exe. 500 only means a basic error has ...
  • 9,696
4 votes
Accepted

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Based on the chat conversion, we have tried to trace the root cause of 500 internal server error and finally, we found out the OP has used SOAP web service, so it should return XML instead of json ...
4 votes

Getting assign to by rest

The AssignTo field is people/group field so we need to expand the field to get information from the field and in rest we need to specify the internal name of the field not the display name example in ...
  • 1,728
4 votes
Accepted

How to use SharePoint REST API to get newest list item?

The URL and endpoint seems right. But in success, you will get the return data in data.d.results array. So you can extract the ID of item from data.d.results array. In this case, You will not get ...
  • 30.7k
3 votes
Accepted

Get distinct values via mechanism used when clicking "Show Filter Choices" on a Sharepoint list using Javascript

I believe the simplest and recommended way to achieve this is using either the SharePoint JavaScript Object Model or AJAX. Neither will cause the page to become unresponsive and both should be fast, ...
3 votes

Not able to access sharepoint list using rest api

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 ...
3 votes

Is AJAX Built-in in SharePoint-Online ( SharePoint-Hosted Apps )?

No Its not built in, you need to add reference to jQuery - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> to the head of the script tag. You can ...
3 votes
Accepted

Hide a specific list from 'View All Site Content' using JSOM/CSOM?

Try this var list = ctx.Web.Lists.GetByTitle(listTitle); list.Hidden = true; list.Update(); ctx.ExecuteQuery(); Source: Hide document library using CSOM Note that in the source they use ...
3 votes
Accepted

REST Add List Item of Custom Content Type

You don't have to deal with __metadata. Just specify your ContentTypeId in your request body and that's all. data: JSON.stringify({ __metadata: { "type": "SP.Data....
3 votes
Accepted

Get item count in a list with filter

The problem is $count return a plain text not a json so you call should be change from: headers: { "Accept": "application/json; odata=verbose" } To headers: { "Accept": "text/plain;odata=verbose" } ...
  • 1,034
3 votes
Accepted

Connected Visual Webpart - RegisterAsyncPostBackControl is not working?

Credit goes to @KenHansen, Updated the code as below and it works <td> <asp:UpdatePanel ID="btApplyFilterPanel" runat="server"> <ContentTemplate> ...
  • 2,498
3 votes
Accepted

displaying ajax query results in usable format

Ok, so I think it's a little easier to see the structure if you open your browser tools and do console.log(data.d.results) instead of alert (no need for JSON.stringify). Where you see the square ...
  • 12.3k
3 votes
Accepted

Rest API Post Request Returns '403 Forbidden'

You can directly use the FormDigestValue in the RequestDigest header in Modern pages. The __REQUESTDIGEST is a hidden HTML element which is not present in modern pages. So, it had tripped up your ...
  • 30.5k
3 votes
Accepted

Corrupt or blank file when downloaded from Sharepoint using rest API ajax call javascript

As we have seen in this problem, mentioning responseType :'arraybuffer' or responseType :'blob', or using 'binaryStringResponseBody:true' didn't help. In all cases we were getting the response but it ...
  • 1,213
2 votes

SharePoint 2013 Rest API OData Query

It's not clear exactly what you want to do, but OData $filter has a startswith that you should be able to use here. $filter=startswith(City_Name_EN,'M') See this page: http://msdn.microsoft.com/en-...

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