I am pulling data from a SharePoint list with listData.svc, and _metadata represent more than half of the response content.

Is there a way to return list fields only, without the metadata?

Below an example in JSON format, atom has a similar issue. What I really want is the data in bold.

{ "__metadata": { "uri": "http:/.../_vti_bin/listdata.svc/Contacts(2988)", "etag": "W/\"3\"", "type": "Microsoft.SharePoint.DataService.ContactsItem" }, "Contact": "christophe", "EmailAddress": "christophe@usermanagedsolutions.com", "Account": { "__metadata": { "uri": "http://.../_vti_bin/listdata.svc/Accounts(5570)", "etag": "W/\"5\"", "type": "Microsoft.SharePoint.DataService.AccountsItem" }, "Account": "Car Rental Inc" } }

link|improve this question

53% accept rate
How or where are you handling the response from the data service? Are you handling client-side (ie. javascript) or server-side? – Alban Jan 5 at 15:29
Client side. The objective is to build dynamic pages that respond to user actions. – Christophe Jan 5 at 17:22
feedback

2 Answers

up vote 3 down vote accepted

Well, I am not absolutely sure, but I think the answer is: there is no way to skip metadata property. You may of course create a kind of proxy by implementing a custom web service which itself consumes listdata.svc and truncates the "__metadata" property? But it doesn't sound good to me.

You can of couse skip all other unnecessary properties by defining the properties in an explicit way:

/_vti_bin/listdata.svc/Contacts()?$select=Contact,Account

But I suppose, you already do this.

This metadata biest is still there. I hope someone can disprove my answer :)

link|improve this answer
Right, I explicitly select the fields. And because Account is a lookup, SharePoint serves two sets of metadata, one for the current list and one for the lookup list. – Christophe Jan 5 at 18:35
feedback

This is a shot in the dark. As you said in your comment, you are building pages dynamically. I am not sure about this, but, I tend to think that if you have a view for the page that the data will be returned OUTSIDE of the metadata as you would expect. I have experienced this with lists.asmx, in that, field/column information or metadata would be returned in metainfo columns. If the fields were present in a view, then these fields were not apart of the metainfo columns. For my unique case, I created a specific view for my scenario, so my particular fields would appear normally in my response results. Again, my scenario has to do with lists.asmx, and I wonder if this could be similar. I wish I could give something concrete, but like I mentioned in the beginning, it is a shot in the dark.

If my theory is correct, verify that the view for this page contains the fields that you want returned in the results.

link|improve this answer
I'll try that. lists.asmx can target a view, but I don't know if the REST API can do it. – Christophe Jan 5 at 17:57
Apparently you cannot select a view with REST services, only use filters on the whole list. – Christophe Jan 5 at 21:17
Indeed, I targeted a specific view that basically contained all of the fields that needed to be returned in the response, and I would dynamically generate a view with the fields I needed if the view did not exist. In this case, lists.asmx and views.amsx were very powerful, but a pain in the arse to use. – Alban Jan 5 at 23:01
However, for other instances, I make substantial use of a service that encapsulates listdata.svc. The great thing is that you get a DataContext with stongly-typed objects when you use listdata.svc. However, I'm not sure you can achieve this with dynamic lists. With my experience, anytime you make a change to a list or library, the data service tied to the datacontext will have to be updated. – Alban Jan 5 at 23:01
What are you using to dynamically create these pages? Have you verified that the default view for your dynamically-created page or pages actually contain the fields for which you are looking? – Alban Jan 6 at 0:36
show 2 more comments
feedback

Your Answer

 
or
required, but never shown

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