![]() |
Stephane Eyskens |
![]() |
Book on SharePoint Development |
![]() |
Most Valuable Professional |
![]() |
Microsoft Certified Professional |
Hi All,
I've recently digged into the new WCF services of SharePoint 2010 and discovered some troubles with it. If you follow the steps mentioned on the following URL:
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/21/introduction-to-querying-lists-with-rest-and-listdata-svc-in-sharepoint-2010.aspx , you'll notice that reproducing his example works fine.
However, when trying to go further and to query some data such as the following piece of code:

You might end up with the following error message:
Request version '1.0' is too low for the response. The lowest supported version is '2.0'. However, I noticed that trying to perform the same query directly via the Browser:
http://sp2010fr/_vti_bin/listdata.svc/Suggestions
returned the expected results. Therefore, the problem was really in the request itself. I decided to compare the HTTP request performed by the browser with the one performed by the above code with Fiddler and this is where I found this difference:
With the browser:

and with the code:

So, we clearly see that the browser sets DataServiceVersion to 2.0 instead of 1.0 as done by the code. I kept looking for a solution by trying to track what was done by the DLL with Reflector and it seemed that the DataVersion couldn't be changed dynamically...So, I just tried to upgrade the target framework of my console program to .NET 4 and guess what => it worked.
As some SharePoint server APIs are not compatible with .NET 4, I'm used to build my projects in .NET 3.5 but in this case, it seems that you must use .NET 4 to make it working but this is pure theory since I didn't find any confirmation elsewhere.
This would mean that you couldn't run that kind of code on the server or at least not combine server APIs and client APIs in the same project...I also tried to use the Dotnet Client Object Model with .NET 4 and it was ok.
Happy coding!