I have a .NET project that needs to add a list item to a Sharepoint 2010 list. After doing a bit of reading I though that using the RESTful services that come with SharePoint 2010 would be a good way to do this.

When I run the code, I have no errors returned and if I run the REST service _vti_bin/listdata.svc/ReturnToWork I can see my new entries in the list. However, when I browse my list via the SharePoint site, the entries are not there.

My code is:-

AttendDataContext context = new AttendDataContext(new Uri(ConfigurationManager.AppSettings["AMS.SharePoint.URL"]));
    string sUserName = ConfigurationManager.AppSettings["AMS.SharePoint.UserName"];
    string sPassword = ConfigurationManager.AppSettings["AMS.SharePoint.Password"];
    string sDomain = ConfigurationManager.AppSettings["AMS.SharePoint.Domain"];      

    public void AddReturnToWork(tAbsence oAbsence, tEmployee oManager)
        ReturnToWorkItem oRTWItem = new ReturnToWorkItem();
        oRTWItem.Title = String.Format("{0}, {1} ({2}) : {3}", oAbsence.tEmployee.LastName, oAbsence.tEmployee.FirstName,
            oAbsence.tEmployee.EmployeeNo, oAbsence.AbsenceStartDate);
        oRTWItem.Site = oAbsence.tEmployee.Site;
        oRTWItem.Department = oAbsence.tEmployee.Department;
        oRTWItem.Manager = String.Format("{0}, {1} ({2})", oManager.LastName, oManager.FirstName, oManager.EmployeeNo);
        oRTWItem.AbsenceID = oAbsence.AbsenceID;
        oRTWItem.Employee = String.Format("{0}, {1} ({2})", oAbsence.tEmployee.LastName, oAbsence.tEmployee.FirstName,
        oRTWItem.AbsenceStartDate = oAbsence.AbsenceStartDate;
        oRTWItem.ReasonForAbsence = oAbsence.Reason;
        oRTWItem.RTWDate = oAbsence.RTWDate;
        oRTWItem.WorksAccident = false;
        oRTWItem.AccidentDate = oAbsence.AbsenceStartDate;
        oRTWItem.PINs = String.Format("{0}{1}", oAbsence.tEmployee.PIN, oManager.PIN);
        oRTWItem.EmployeePin = oAbsence.tEmployee.PIN;
        oRTWItem.ManagerPin = oManager.PIN;
        ReturnToWorkRTWStatusValue oRTWValue = new ReturnToWorkRTWStatusValue();
        oRTWValue.Value = "New";
        oRTWItem.RTWStatus = oRTWValue;

        context.Credentials = new System.Net.NetworkCredential(sUserName, sPassword, sDomain);


Can anybody advise what I've missed?


Apologies. It turns out the code was adding the records, but due to the volume of records already in the list I was filtering to find the records and the column I was filtering on (RTWStatus) was not populated with the value 'New' that I expected.

Just for information purposes, I've rejigged the code anyway to be slightly more readable (IMHO) and displayed below

    new ReturnToWorkItem()
        Title = String.Format("{0}, {1} ({2}) : {3}", oAbsence.tEmployee.LastName,
        oAbsence.tEmployee.FirstName, oAbsence.tEmployee.EmployeeNo,
        Site = oAbsence.tEmployee.Site,
        Department = oAbsence.tEmployee.Department,
        Manager = String.Format("{0}, {1} ({2})", oManager.LastName, oManager.FirstName, oManager.EmployeeNo),
        AbsenceID = oAbsence.AbsenceID,
        Employee = String.Format("{0}, {1} ({2})", oAbsence.tEmployee.LastName,
            oAbsence.tEmployee.FirstName, oAbsence.tEmployee.EmployeeNo),
        AbsenceStartDate = oAbsence.AbsenceStartDate,
        ReasonForAbsence = oAbsence.Reason,
        RTWDate = oAbsence.RTWDate,
        WorksAccident = false,
        AccidentDate = oAbsence.AbsenceStartDate,
        PINs = String.Format("{0}{1}", oAbsence.tEmployee.PIN, oManager.PIN),
        EmployeePin = oAbsence.tEmployee.PIN,
        ManagerPin = oManager.PIN,
        RTWStatus = new ReturnToWorkRTWStatusValue()
            Value = "New"

The RTWStatus still isn't being populated, but that's another problem entirely!

  • Just for completeness....the issue with populating the RTWStatus column, which is a choice field, was resolved by using this instead:- RTWStatusValue = "New" Fiddler is a great help for checking the REST queries :-) – grimorde Oct 19 '10 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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