1

I was making a rest api call with Odata filter author/id. I want to get survey responses of a particular user.

_api/Web/Lists(guid'id')/items?$select=Id,Author/ID&$expand=Author/ID&$filter=(Author/ID eq 21)

But I am getting an error :

The field 'Author' of type 'User' cannot be used in the query filter expression.

How to resolve this issue?

5

You are missing ID in expand. The query should look like: _api/Web/Lists(guid'id')/items?$select=Id,Author/ID&$expand=Author/ID&$filter=(Author/ID eq 21)

  • I added ID also in expand. Even then it is not working. Throwing the same error – Praveen Prasannan Apr 3 '14 at 5:15
  • try using &$filter=Author/ID eq '21' or &$filter=Author/ID eq 21 – Nadeem Yousuf Apr 3 '14 at 5:25
  • Same error. Is this author a reserve keyword or something? – Praveen Prasannan Apr 3 '14 at 5:29
  • As per the last comment in this blog post sympmarc.com/2014/01/21/…, Author can be used in filter expression: &$filter=Author/FirstName eq 'Shelly' – Nadeem Yousuf Apr 3 '14 at 5:36
  • Same error. Not working. – Praveen Prasannan Apr 3 '14 at 7:23
1

There is no need to use $expand operator if you don't need to return the projected fields.

The following REST endpoint demonstrates how to filter by Author Id:

/_api/Web/Lists/getByTitle('Tasks')/items?$filter=(AuthorId eq 12)
  • Am getting below error: Column 'AuthorId' does not exist. It may have been deleted by another user. /Lists/Map functionality – Praveen Prasannan Apr 3 '14 at 7:20
  • Make sure you have an Author field in your list – Vadim Gremyachev Apr 3 '14 at 7:59
  • yes. It is there if we select all fields of that list. I doubt SharePoint use it internally – Praveen Prasannan Apr 3 '14 at 8:00
0

You can update your query as

/_api/Web/Lists/getByTitle('Tasks')/items?$filter=(Author eq 12)

The SharePoint REST removes the Id appended to any of the lookup Field or people-picker

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.