E
ehubba
Guest
Trying to update a SharePoint Record, however am getting Error 400 Bad Request when it tries to execute. Now on another list with another application I have, all with exact permissions, there is no issues updating an existing record. Only on this new list. Im using the same coding which Ive used before. Also to note, when calling to collect data from SharePoint, there is no errors. Only then trying to update.
Code:
SharePointSvce.Lists listService = new SharePointSvce.Lists();
//listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
listService.Credentials = LoadCredentials();
listService.Url = SharePoint Website
// Choose the list and the view. Remember to substitute the values with the actual
// List GUID and View GUID that you want to work with.
string listGUID = "539FC948-8326-4E91-92EB-979246503ECE";
string activeItemViewGUID = "809F061E-27DE-470F-AB6B-450C65B77109";
XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
elBatch.SetAttribute("ListVersion", "1");
elBatch.SetAttribute(listGUID, activeItemViewGUID);
elBatch.InnerXml = "<Method ID=1 Cmd=Update>" +
"<Field Name=ID>" + GlobalVariables.getUser_Index + "</Field>" +
"<Field Name=LinkTitle>" + GlobalVariables.getUser_AgentID + "</Field>" +
"<Field Name=Login_x0020_Password>" + GlobalVariables.getUser_AgentIDPassword + "</Field>" +
"<Field Name=Login>" + GlobalVariables.getUser_AgentLogin + "</Field>" +
"<Field Name=Name>" + Environment.UserName + "</Field>" +
"<Field Name=Updated>" + DateTime.Now.ToString() + "</Field>" +
"</Method>";
try
{
XmlNode ndReturn = listService.UpdateListItems(listGUID, elBatch);
if (!ndReturn.InnerText.Contains("0x00000000")) //Code reflects zero errors occurred
{
//MessageBox.Show(ndReturn.OuterXml);
Exception ex = new Exception(ndReturn.OuterXml);
throw ex;
}
}
catch (System.Web.Services.Protocols.SoapException ex)
{
//MessageBox.Show(ex.Message);
throw ex;
}
Any thoughts as to what could be causing the error?
Thanks!
Continue reading...
Code:
SharePointSvce.Lists listService = new SharePointSvce.Lists();
//listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
listService.Credentials = LoadCredentials();
listService.Url = SharePoint Website
// Choose the list and the view. Remember to substitute the values with the actual
// List GUID and View GUID that you want to work with.
string listGUID = "539FC948-8326-4E91-92EB-979246503ECE";
string activeItemViewGUID = "809F061E-27DE-470F-AB6B-450C65B77109";
XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError", "Continue");
elBatch.SetAttribute("ListVersion", "1");
elBatch.SetAttribute(listGUID, activeItemViewGUID);
elBatch.InnerXml = "<Method ID=1 Cmd=Update>" +
"<Field Name=ID>" + GlobalVariables.getUser_Index + "</Field>" +
"<Field Name=LinkTitle>" + GlobalVariables.getUser_AgentID + "</Field>" +
"<Field Name=Login_x0020_Password>" + GlobalVariables.getUser_AgentIDPassword + "</Field>" +
"<Field Name=Login>" + GlobalVariables.getUser_AgentLogin + "</Field>" +
"<Field Name=Name>" + Environment.UserName + "</Field>" +
"<Field Name=Updated>" + DateTime.Now.ToString() + "</Field>" +
"</Method>";
try
{
XmlNode ndReturn = listService.UpdateListItems(listGUID, elBatch);
if (!ndReturn.InnerText.Contains("0x00000000")) //Code reflects zero errors occurred
{
//MessageBox.Show(ndReturn.OuterXml);
Exception ex = new Exception(ndReturn.OuterXml);
throw ex;
}
}
catch (System.Web.Services.Protocols.SoapException ex)
{
//MessageBox.Show(ex.Message);
throw ex;
}
Any thoughts as to what could be causing the error?
Thanks!
Continue reading...