I am putting together some demos for SharePoint 2010, and one of the demos I really wanted to show off was building a Windows Forms application that talks to SharePoint 2010’s REST services.  If you haven’t seen this in action yet, you owe it to yourself to watch this session from PDC (http://microsoftpdc.com/Sessions/PR12).  Maxim Lukiyanov does a fantastic job of demonstrating the power of SharePoint and WCF Data Services.

Maxim shows a Windows Forms application with two GridViews that bind to SharePoint data.  I followed Maxim’s steps exactly to recreate the application, hit F5, and… nothing.  The form shows up, but the grids are empty.  Huh?  I tried a few of the usual suspects, including making sure the URL was entered correctly, tried running the app as administrator, even specifying network credentials… no joy.

Knowing that WCF Data Services is just making HTTP calls, I fired up Fiddler to see what is going on.  I run my application, and sure enough I see an error 400 immediately.

image

You can see what’s going on pretty easily.  In the request, there is a DataServiceVersion header sent in the request with a value of 1.0;NetFx.  The response shows the error message:

Request version '1.0' is too low for the response. The lowest supported version is '2.0'.

OK, we’ve identified the problem, now how to fix it?  Some quick searching, and I found a blog that mentions the same problem with DataServiceVersion.  The fix was to simply change the Console application’s target framework from 3.5 to 4.

image

Run the application one more time, and presto!

image

Again, if you haven’t seen this demo, you owe it to yourself to see how this was built and just how little effort it takes to build it.