I'm having very specific trouble using the SharePoint 2010 REST interfaces with a multi-choice column (e.g. a set of checkboxes). Single choice columns work fine (e.g. radio buttons or dropdown, and even yes/no columns all work ok.
- I have a list 'Flight' on SharePoint with a multi-choice column 'Equipment'
- in C#, .NET 4.0, I add a Service Reference to the site's RESTful service
- in the Object Browser in VC# Express, I see the Flight object
- there is also a FlightEquipmentValue type and a DataServiceCollection Equipment property to set.
I'm able to instantiate a new context for the service, create a new item, set its other properties. Then I can call FlightEquipmentValue.CreateFlightEquipmentValue() to create a new 'holder' for a checkbox value and add one of my choices to the list of equipment (e.g. "Beverage Cart").
When I inspect the Flight object in the debugger after adding the equipment, everything looks great. When I save the object with SaveChanges(), the new list item is created in SharePoint.
Except that the Equipment field is blank, nothing is ever set.
After trying everything I could think of to set the value (e.g. AttachLink()), .... I sniffed the data going across the wire to the SharePoint service with Fiddler.
The rest of the Flight object is "serialized" there but not the Equipment field. Nothing at all.
Help needed, thanks.
static void Main(string[] args)
{
Uri uri = new Uri(args[0]);
Console.WriteLine("Forwarding: to " + uri);
HomeDataContext context =
new HomeDataContext(uri);
context.Credentials = new System.Net.NetworkCredential(args[1], args[2]);
FlightsItem flight = new FlightsItem();
flight.FlightNumber = "79";
flight.Pilot = "Bill";
flight.Copilot = "Susan";
flight.Aircraft = FlightsAircraftValue.CreateFlightsAircraftValue("Boeing 747");
flight.AircraftValue = "Boing 737";
FlightsEquipmentValue equip = FlightsEquipmentValue.CreateFlightsEquipmentValue("Beverage Cart");
flight.Equipment.Add(equip);
context.AddToFlights(flight);
context.SaveChanges();
}
Here's the POST over the wire:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://www.w3.org/2005/Atom">
<category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"
term="Microsoft.SharePoint.DataService.FlightsItem" />
<title type="text">79</title>
<updated>0001-01-01T00:00:00Z</updated>
<author>
<name />
</author>
<id />
<content type="application/xml">
<m:properties>
<d:AircraftValue m:null="true" />
<d:ContentType m:null="true" />
<d:ContentTypeID m:null="true" />
<d:Copilot>Susan</d:Copilot>
<d:Created m:type="Edm.DateTime" m:null="true" />
<d:CreatedById m:type="Edm.Int32" m:null="true" />
<d:FlightNumber>79</d:FlightNumber>
<d:Id m:type="Edm.Int32">0</d:Id>
<d:Modified m:type="Edm.DateTime" m:null="true" />
<d:ModifiedById m:type="Edm.Int32" m:null="true" />
<d:Owshiddenversion m:type="Edm.Int32" m:null="true" />
<d:Path m:null="true" />
<d:Pilot>Bill</d:Pilot>
<d:Version m:null="true" />
</m:properties>
</content>
</entry>