1

I have my multi-value SPUser field in my list. When accessing it via REST, I am only able to retrieve the ID of the SPUsers. In the result of the REST, the SPUser field was also appended by an Id in the column name. I would need to retrieve the Names of the user, what would be the easiest and most practical way to do it?

enter image description here

1

1 Answer 1

1

It is the way SharePoint works. For lookup column it returns the Id only. If you need more information from lookup column, then just use $expand in your query. For example

/_api/Web/Lists/GetByTitle('SpTutorial')/Items?$select=SPUser/Title&$expand=SPUser

Result without $expand

"SpUsersId": {
    "__metadata": {
      "type": "Collection(Edm.Int32)"
    },
    "results": [
      33,
      22
    ]
  }

Result with $expand

"SpUsers": {
    "results": [
      {
        "__metadata": {
          "id": "e9a1d4f9-5d6d-4a4c-8753-ce1b5020b125",
          "type": "SP.Data.UserInfoItem"
        },
        "Title": "Mohammad Mazumder"
      },
      {
        "__metadata": {
          "id": "6d968e6a-830a-4997-bba3-035dc1acdc85",
          "type": "SP.Data.UserInfoItem"
        },
        "Title": "Admin"
      }
    ]
  }

Check more about REST API in my article.

CRUD Operation to List Using SharePoint 2013 Rest API

3
  • Hi Atish, I am not sure why it is not working while I was trying with my SPUser field. I am getting "The $expand query is not valid for field 'HOD'" Here is my query "/_api/web/lists/getbytitle('" + listTitle + "')/getitems?$select=HOD/Title&$expand=HOD" Any thoughts? I have both internal name and display name of my field as "HOD"
    – Joe
    Nov 11, 2015 at 2:36
  • Url should be "/_api/web/lists/getbytitle('" + listTitle + "')/Items?$select=HOD/Title&$expand=HOD". use Item instead of getitems. Nov 11, 2015 at 2:55
  • Got it working now. I changed the way I call the rest. Thanks a lot!
    – Joe
    Nov 11, 2015 at 2:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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