0

I know using server side code I can use GetListItem(url) to get an item using a server relative/absolute url (such as this question) however I cant seem to find the same code using the Client Object Model. Can anyone tell me if there is a similar one or do I have to approximate my own?

Mauro
  • 1,110
  • 13
  • 26

1 Answers1

1

Try this in the Client Object Model:

var fileItem = Web.GetFileByServerRelativeUrl("server/relative/url");

context.Load(fileItem); //you will probably need to load the ListItemAllFields property here.
context.ExecuteQuery();

var listItem = fileItem.ListItemAllFields; 

Console.WriteLine(listItem["Title"]);
Vardhaman Deshpande
  • 10,462
  • 1
  • 26
  • 52