0

I am having a problem with the $expand operator in SharePoint Onlineand hopefully you have a simple answer.

_api/web/lists/GetbyTitle('LinkList')/Items?$select=Project/Title,Project/Due_x0020_Date&$expand=Project

This returns the details as expected.

_api/web/lists/GetbyTitle('LinkList')/Items?$select=Project/Title,Project/Due_x0020_Date,Project/Author&$expand=Project

This returns:

The query to field 'Project/Author' is not valid.

even though Author exists on every list

I thought that maybe doing an expand on an expand isn't possible so i thought that I could just return the AuthorId

_api/web/lists/GetbyTitle('LinkList')/Items?$select=Project/Title,Project/Due_x0020_Date,Project/AuthorId&$expand=Project

But that returns

"The query to field 'Project/AuthorId' is not valid."

_api/web/lists/GetbyTitle('Project')/items?$select=Title, AuthorId

This returns as expected with the item title and the AuthorId

Am I trying to do something that isn't possible or am i just messing up the syntax somewhere?

1

What you are trying to do is not possible. The "Author" column is a built-in lookup field. In your query you are trying to make a lookup (Project) to another lookup (Author).

You will see this limitation if you try to create a column in a list that is a lookup to another lookup field. SharePoint will not allow this.

  • Thanks Alex, you are correct it is a lookup field. The listdata.svc allows you to do this expand, do you know what reason they have from removing this functionality fro the _api interface? – Mitchell Hunt Mar 27 '16 at 22:43
  • I wish I knew more, but I do not know why. I had tried researching this before and I think it is just a limitation of SharePoint Online. I feel Microsoft did a very poor job of documenting limitations like this in SPO. I found myself consistently running into roadblocks that were not mentioned anywhere in the docs. Sorry I couldn't be more help. – Alex Chance Mar 28 '16 at 13:19
0

I suppose, "Project" is a lookup column in your LinkList.

Can you try this query and see if you get the required properties first:

 _api/web/lists/GetbyTitle('LinkList')/Items?$expand=Project

If you get both the project Due date and Title, it resolves your issue.

To refine further you need to check the property names in the response to see if they are actually 'Title' and 'Author' or not. By my guess they should be different.

  • Thanks for the suggestion. When I do that query i get The query to field 'Project' is not valid. The $select query string must specify the target fields and the $expand query string must contains Project. – Mitchell Hunt Mar 27 '16 at 22:41

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.