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,
oAbsence.tEmployee.EmployeeNo);
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);
context.AddToReturnToWork(oRTWItem);
context.SaveChanges();
Can anybody advise what I've missed?