0
나는 성공이 라인이 .asmx 웹 서비스에 ClientContext를 만드는 방법
list.Credentials = new System.Net.NetworkCredential("domain\\username", "password");
에 연결하지만 ClientContext
web service
에 참가할 수 없습니다 : 나는 새 항목을 추가하는 방법 오류 401이 원격 SPSite에 SPList에 도착 암호? 내가 고쳐야 할게 뭐야? 고맙습니다.
public void UpdateSPList(string Title)
{
using (AuthenticationSvc.Authentication authSvc = new AuthenticationSvc.Authentication())
{
try
{
using (ListsSvc.Lists list = new ListsSvc.Lists())
{
list.Url = @"http://example-site.com/_vti_bin/Lists.asmx";
list.CookieContainer = new System.Net.CookieContainer();
list.AllowAutoRedirect = true;
list.PreAuthenticate = true;
list.Credentials = new System.Net.NetworkCredential("domain\\username", "password");
string siteUrl = "http://example-site.com";
ClientContext context = new ClientContext(siteUrl);
List announcementsList = context.Web.Lists.GetByTitle("ListName");
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem newItem = announcementsList.AddItem(itemCreateInfo);
newItem["Title"] = "New Item";
newItem.Update();
context.ExecuteQuery();
}
}
catch (Exception ex)
{
string errorEntry = ex.Message;
}
}
}