From: throstur on 3 Jul 2006 09:44 When I programmatically use web services I get an error: The request failed with HTTP status 401: Unauthorized. The user running the program has the following sharepoint rights: Full Control Do I need any other rights? Or any machine or domain specific rights. (Every thing works fine in my development environment but problem when I set this up at the customer site) Regards, Throstur
From: adam@sharepointsecurity.com on 3 Jul 2006 09:53 Could you be more specific with the error? Do you mean you are consuming a SharePoint webserivce? Did you have an impersonation setup? Adam Buenz http://www.sharepointsecurity.com MVP -- Windows SharePoint Services "throstur" wrote: > When I programmatically use web services I get an error: > > The request failed with HTTP status 401: Unauthorized. > > The user running the program has the following sharepoint rights: Full Control > > Do I need any other rights? Or any machine or domain specific rights. > > (Every thing works fine in my development environment but problem when > I set this up at the customer site) > > Regards, > Throstur > >
From: throstur on 4 Jul 2006 06:50 My class is below and the impersination line: listService.Credentials = System.Net.CredentialCache.DefaultCredentials; I'll paste the error at the end of this document. Like I said it works in my development environment. public class TaskList { public static KeyInfo Add(string strTitle, string strAssignedTo, string strStatus,string strPriority,string strApplication,string strDrugName, string strDesc) { SPListService.Lists listService = new SPListService.Lists(); listService.Url = ConfigurationManager.AppSettings["SPListService.Lists"]; listService.Credentials = System.Net.CredentialCache.DefaultCredentials; //XmlNode listar = listService.GetListCollection(); XmlNode field = listService.GetList("Tasks"); ////Get list from SPS //System.Xml.XmlNode tasks = listService.GetListItems("Tasks", null, null, null, null, null); //Add item to SPS list and get ID XmlDocument xmlAdd = new XmlDocument(); //create root XmlElement batch = xmlAdd.CreateElement("Batch"); batch.SetAttribute("OnError", "Return"); xmlAdd.AppendChild(batch); //create method element XmlElement method = xmlAdd.CreateElement("Method"); method.SetAttribute("ID", "1"); method.SetAttribute("Cmd", "New"); batch.AppendChild(method); //create fields XmlElement field1 = xmlAdd.CreateElement("Field"); field1.SetAttribute("Name", "ID"); field1.AppendChild(xmlAdd.CreateTextNode("New")); method.AppendChild(field1); XmlElement field2 = xmlAdd.CreateElement("Field"); field2.SetAttribute("Name", "Title"); field2.AppendChild(xmlAdd.CreateTextNode(strTitle)); method.AppendChild(field2); XmlElement field3 = xmlAdd.CreateElement("Field"); field3.SetAttribute("Name", "AssignedTo"); field3.AppendChild(xmlAdd.CreateTextNode(strAssignedTo)); method.AppendChild(field3); XmlElement field4 = xmlAdd.CreateElement("Field"); field4.SetAttribute("Name", "Status"); field4.AppendChild(xmlAdd.CreateTextNode(strStatus)); method.AppendChild(field4); XmlElement field5 = xmlAdd.CreateElement("Field"); field5.SetAttribute("Name", "Priority"); field5.AppendChild(xmlAdd.CreateTextNode(strPriority)); method.AppendChild(field5); XmlElement field6 = xmlAdd.CreateElement("Field"); field6.SetAttribute("Name", "Appliction"); field6.AppendChild(xmlAdd.CreateTextNode(strApplication)); method.AppendChild(field6); XmlElement field7 = xmlAdd.CreateElement("Field"); field7.SetAttribute("Name", "Drug_x0020_name"); field7.AppendChild(xmlAdd.CreateTextNode(strDrugName)); method.AppendChild(field7); XmlElement field8 = xmlAdd.CreateElement("Field"); field8.SetAttribute("Name", "Body"); field8.AppendChild(xmlAdd.CreateTextNode(strDesc)); method.AppendChild(field8); XmlNode response = listService.UpdateListItems("Tasks", batch); //Dispose of listservice listService.Dispose(); string error = response.InnerText; XmlNode result = response.FirstChild; string data = result.LastChild.OuterXml.ToString(); int pos = data.IndexOf("ows_ID"); int length = 0; while ((data[pos + 8 + length] >= '0') && (data[pos + 8 + length] <= '9')) length++; string id = data.Substring(pos + 8, length); KeyInfo Key = new KeyInfo(); Key.ErrorCode = error; Key.ID = id; return Key; } public static void Update(string strID,string strCancelled) { SPListService.Lists listService = new SPListService.Lists(); listService.Credentials = System.Net.CredentialCache.DefaultCredentials; //XmlNode listar = listService.GetListCollection(); ////Get list from SPS //System.Xml.XmlNode tasks = listService.GetListItems("Tasks", null, null, null, null, null); //Update SPS listitem // Create a new XML document to hold the updates we are going to perform XmlDocument doc = new XmlDocument(); XmlElement updates = doc.CreateElement("Batch"); updates.SetAttribute("OnError", "Return"); // We need to Create a Method Tag for each row we are going to update. XmlElement UpdatesMethod = doc.CreateElement("Method"); UpdatesMethod.SetAttribute("ID", "1"); UpdatesMethod.SetAttribute("Cmd", "Update"); updates.AppendChild(UpdatesMethod); // We need to update a particular row based on its internal ID. XmlElement UpdatesField1 = doc.CreateElement("Field"); UpdatesField1.SetAttribute("Name", "ID"); // Which record to update UpdatesField1.InnerText = strID; // is defined here UpdatesMethod.AppendChild(UpdatesField1); // We are going to update the field called "Canceled" XmlElement UpdatesField2 = doc.CreateElement("Field"); UpdatesField2.SetAttribute("Name", "Canceled"); // Which field to update UpdatesField2.InnerText = strCancelled; // The actual new value UpdatesMethod.AppendChild(UpdatesField2); // We are going to update the field called "Status" XmlElement UpdatesField3 = doc.CreateElement("Field"); UpdatesField3.SetAttribute("Name", "Status"); // Which field to update UpdatesField3.InnerText = "On Hold"; // The actual new value UpdatesMethod.AppendChild(UpdatesField3); // Call the web service to update the list items XmlNode Result = listService.UpdateListItems("Tasks", updates); //Dispose of listservice listService.Dispose(); } public TaskList() { } } The request failed with HTTP status 401: Unauthorized. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized. Source Error: Line 323: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetList", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] Line 324: public System.Xml.XmlNode GetList(string listName) { Line 325: object[] results = this.Invoke("GetList", new object[] { Line 326: listName}); Line 327: return ((System.Xml.XmlNode)(results[0])); Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\dams\cfc0f926\39c51152\App_WebReferences.czk-ckcp.0.cs Line: 325 Stack Trace: [WebException: The request failed with HTTP status 401: Unauthorized.] System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +533199 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204 SPListService.Lists.GetList(String listName) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\dams\cfc0f926\39c51152\App_WebReferences.czk-ckcp.0.cs:325 SPListsLibrary.TaskList.Add(String strTitle, String strAssignedTo, String strStatus, String strPriority, String strApplication, String strDrugName, String strDesc) in c:\Inetpub\wwwroot\DAMS\App_Code\SPListsLibrary.cs:344 ApplicationTasks.ASPxButton1_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\DAMS\ApplicationTasks.aspx.cs:95 DevExpress.Web.ASPxDataControls.ASPxButton.OnClick(EventArgs e) +75 DevExpress.Web.ASPxDataControls.ASPxButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +282 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102 -------------------------------------------------------------------------------- "adam(a)sharepointsecurity.com" wrote: > Could you be more specific with the error? > > Do you mean you are consuming a SharePoint webserivce? > > Did you have an impersonation setup? > > Adam Buenz > http://www.sharepointsecurity.com > MVP -- Windows SharePoint Services > > "throstur" wrote: > > > When I programmatically use web services I get an error: > > > > The request failed with HTTP status 401: Unauthorized. > > > > The user running the program has the following sharepoint rights: Full Control > > > > Do I need any other rights? Or any machine or domain specific rights. > > > > (Every thing works fine in my development environment but problem when > > I set this up at the customer site) > > > > Regards, > > Throstur > > > >
From: MCB on 24 Jul 2006 10:40 I am getting same error. Help appreicated.
From: Roland Whitley on 25 Jul 2006 14:24 I am also getting that error... other services (and calls within that service) are working as expected. "MCB" wrote: > I am getting same error. Help appreicated. > >
|
Pages: 1 Prev: SPSAdmin (SPSAdmin) failed to start Next: Manage Permissions |