I am trying to add new item to a custom list using Lists.asmx web service but for some reason I am not able to find out why the date column value is not valid, here is my Method tag:
<Method ID='1' Cmd='New'>
<Field Name='ColDrawingNo'>none</Field>
<Field Name='ColProductType'>none</Field>
<Field Name='ColNo'>1576</Field>
<Field Name='ColBranch'>12;#TEST</Field>
<Field Name='ColIssueDate'>2005-01-03T00:00:00Z</Field> //this field is set to Date only
</Method>
and this is passed to lists service using the following:
XmlDocument xmlDocList = new XmlDocument();
XmlElement elBatch = xmlDocList.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
elBatch.InnerXml = sbMethod.ToString();
xmlNode ndReturn = wsLists.UpdateListItems("TestList", elBatch);
ndReturn contains this error message:
0x8102001cInvalid date/time value
A date/time field contains invalid data. Please check the value and try again.
The ColIssueDate is converted to the required format using:
SPUtility.CreateISO8601DateTimeFromSystemDateTime(Convert.ToDateTime(dr[s.ToString()].ToString())); //dr is datarow
There are more columns in my method tag which are not required fields and all fields are part of content type.
I have also tryied using Date only for ColIssueDate without time part after i came across this code on msdn:
<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
<Method ID="1" Cmd="New">
<Field Name='ID'>New</Field>
<Field Name="Title">Value</Field>
<Field Name="Date_Column">2007-3-25</Field>
<Field Name="Date_Time_Column">
2006-1-11T09:15:30Z</Field>
</Method>
</Batch>
the only thing different here is I am not using any ViewName which i think shouldnt make difference, right?
↧
Lists.asmx UpdateListItems 0x8102001cInvalid date/time value
↧