5

I tried a request at a url of the following form

.../_api/web/Lists/getByTitle('docLib')/items?$select=id,GUID&$top=1&$filter=GUID eq '2779cf8051-381f-4834-93dc-ece6345dde33'

and i get "Microsoft.SharePoint.SPQueryThrottledException : The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator."

I find this very peculiar because a request at

.../_api/web/Lists/getByTitle('docLib')/items

does not give an error and returns the list of all items (I think) in "docLib".

Any other way to get the id of an item by its GUID ?

EDIT:

The error described appears only when searching in a list with more than a few thousand(i think 5000) items. I need something to work regardless of the number of items in the list.

  • Have you try to move the &top=1 to the end of the URL? for some strange reason that works for me sometimes. – cubanGuy Nov 17 '14 at 17:34
  • Have you tried casting? E.g., guid'2779cf8051-381f-4834-93dc-ece6345dde33' – eirikb Mar 6 '15 at 6:27
3

Use the UniqueId instead of GUID. Try the following end url,

.../_api/web/Lists/getByTitle('docLib')/items?$select=id,UniqueId&$top=1&$filter=UniqueId eq '2779cf8051-381f-4834-93dc-ece6345dde33'

This seems work in both on-premise and online environment.

2

Try it without the $top -- no two items in the same list should have the same GUID

This works fine for me on SharePoint Online:

$.getJSON("/_api/web/lists/getByTitle('Documents')/items?$select=GUID&$filter=GUID eq '86ff528f-75d2-48e9-8ce9-e4814ae98e42'", function(data) { console.log(data) })
  • i tried different variants, with and without the top and select. the error i described appears only when searching in a list with more than a few thousand(i think 5000) items. I need something to work regardless of the number of items in the list – Sbiera Bogdan Nov 18 '14 at 7:40
  • The 5000 list item threshold is a well documented limitation of the platform -- support.office.com/client/… -- probably not what you want to hear but you should consider re-architecting to go below 5k for any individual list or switch to a database for handling your particular issue... No API for SP will just 'always work' without regard to that limit – John-M Nov 18 '14 at 14:08
  • Also consider adding an index as a workaround -- more details in that article I linked to – John-M Nov 18 '14 at 14:09
0

As I mentioned in my comments, move the &Top=1 to the end of the URL.

.../_api/web/Lists/getByTitle('docLib')/items?$select=id,GUID&$filter=GUID eq '2779cf8051-381f-4834-93dc-ece6345dde33'&$top=1

I noticed that regardless the fact each item has its own GUID, REST seems to ignore it in this case.

0

In my case, I wasn't able to get the other solutions to work, but that using ID worked for me (in the online environment).

/_api/web/lists/GetByTitle('Custom List Name')/items?$select=Title,FieldValuesAsHtml,PublishingPageContent,ID&$filter=ID eq '3'
0

Once a list or library hits the list view threshold (in SharePoint Online it's 5000 items) you're no longer able to filter using non-indexed columns.

If you're anticipating a list to have more than 5000 items you should make sure to create an indexed column for any of the columns that you're planning to filter on. Unfortunately in this case the 'GUID' column is owned by SharePoint, and you're not going to be able to create an index for it.

If you're really stuck on using the 'GUID' value I'd suggest that you create a new text column (ie 'myGUID') along with a corresponding index. Then create a new item workflow that sets 'myGUID' to be equal to 'GUID'. Once that's done you'll be able filter the list using the 'myGUID' column. Of course, you'll still need a way to populate the myGUID values for all of the existing items, but a quick and dirty powershell script or list workflow could easily take care of this.

0

I see your GET request url is correct but you are getting error because your view has more than more than list threshold limit 5000 you are unable to do filter operation.

As we all know creating multiple views to avoid this limitation on a list. So you can try POST request by passing view xml using REST api.

The syntax would be as follows. This you have to do using POST request

siteurl/_api/web/Lists/GetByTitle('list title')/GetItems(query=@v1)?@v1={"ViewXml":"<View><Query><Where><Eq><FieldRef Name='GUID'/><Value Type='Guid'>your guid</Value></Eq></Where></Query></View>"}
0

Unforunately, at thi moment 2019,there is not way to get by GUID an Item or just the ID and GUID is not indexed yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.