4

This test

/_api/web/lists/GetByTitle('doclib1')/items?$select=ID,DocIcon,LinkFilename,Modified,Editor/Title,UniqueId,GUID&$expand=Editor

returns me

    {
  "d": {
    "results": [
      {
        "__metadata": {
          "id": "b9c377f3-79cc-466a-b495-5834cff90ce0",
          "uri": "https://quantr.sharepoint.com/test/_api/Web/Lists(guid\u00275d9df756-8067-4599-b1cc-fc9ca610c4fe\u0027)/Items(1)",
          "etag": "\"1\"",
          "type": "SP.Data.Doclib1Item"
        },
        "Editor": {
          "__metadata": {
            "id": "7980221b-5cff-4d10-8350-fed6b6f93894",
            "type": "SP.Data.UserInfoItem"
          },
          "Title": "wordpress"
        },
        "Id": 1,
        "ID": 1,
        "Modified": "2017-12-12T17:08:46Z",
        "UniqueId": "84ea42c1-abb4-466c-a7b4-532fbaf1515a",
        "LinkFilename": "大圍 !",
        "GUID": "f01e761d-0fd4-4d7d-a447-e3bd609bc821"
      },
    }
}

But this test /_api/web/lists/GetByTitle('doclib1')/items?$select=ID,DocIcon,LinkFilename,Modified,Editor/Title,UniqueId,GUID&$expand=Editor&$filter=UniqueId+eq+guid%2784ea42c1-abb4-466c-a7b4-532fbaf1515a%27

returns me empty json.

{
  "d": {
    "results": []
  }
}

If I filter by the GUID, it works again. Is it a bug? UniqueId is unable to be filter?

  • Tested in my Tenant environment, same issue, filter with UniqueId, not return anything, but filter with GUID, it works as expected, I found the same case has been posted here: stackoverflow.com/questions/26074857/… I wonder this should be a problem with Rest API, you can create a feedback to report this issue: office365.uservoice.com – Jerry_MSFT Dec 26 '17 at 7:45
3

Unfortunately, it does not appear that UniqueId is supported as a refinable OData property at the moment. You can still filter by it by using a CAML-query however. Here's an example function that just outputs the result to the console (assumes you're using the classic experience):

function getByUniqueId(listTitle, uniqueId) { 
    var caml = "<View><Query><Where><Eq><FieldRef Name='UniqueId' /><Value Type='Guid'>"+uniqueId+"</Value></Eq></Where></Query></View>";
    var data = { "query" : {"__metadata": 
             { type: "SP.CamlQuery" }, ViewXml:caml}};

    var formDigest = document.getElementById("__REQUESTDIGEST").value; 
    var xhr = new XMLHttpRequest(); 
    xhr.open("POST", _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/GetItems", true); 
    xhr.setRequestHeader("accept","application/json;odata=verbose"); 
    xhr.setRequestHeader("content-type","application/json;odata=verbose"); 
    xhr.setRequestHeader("X-RequestDigest",formDigest); 
    xhr.onreadystatechange = function() { 
        if(xhr.readyState === 4 && xhr.status === 200) { 
            console.log(xhr.responseText);  
        }
    }
    xhr.send(JSON.stringify(data));
}
0

You can filter with Listitem Unique using the method GetItemByUniqueId in Rest API or CSOM. It works for both:

  /_api/web/lists(guid'7b754e56-9b3e-4fad-be8b-81e5c8aff350')/GetItemByUniqueId(guid'1b63edbc-12a7-4287-ad7d-f773aa8d2726')

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.