使用RestSharp在思科ISE上注册端点

本文关键字:注册 端点 ISE RestSharp 使用 | 更新日期: 2023-09-27 18:03:57

我正在尝试通过c#控制台应用程序中的RestSharp客户端在Cisco ISE 1.3上注册(POST)端点。

我已经得到它的工作与GET请求。我使用的代码:

String XML = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?> <ns3:endpoint name='name' id='id' description='Desc' xmlns:ns2='ers.ise.cisco.com'    xmlns:ns3='identity.ers.ise.cisco.com'> <groupId>04f3c120-f42f-11e2-bd54-005056bf2f0a</groupId> <mac>00:00:CC:Ac:BB:CC</mac> <profileId>576bf7b0-f42f-11e2-bd54-005056bf2f0a</profileId><staticGroupAssignment>true</staticGroupAssignment> <staticProfileAssignment>true</staticProfileAssignment> </ns3:endpoint> "; 
var client = new RestClient();
    client.BaseUrl = new Uri("https://" + ip + ":9060/ers/config/endpoint");
    client.Authenticator = new HttpBasicAuthenticator(user, pw);
var request = new RestRequest(); 
    request.Method = Method.POST;
    request.AddHeader("Accept", "application/vnd.com.cisco.ise.identity.endpoint.1.0+xml");
    request.AddHeader("Content-Type", "application/vnd.com.cisco.ise.identity.endpoint.1.0+xml; charset=utf-8");
    request.AddBody(XML);
    request.RequestFormat = DataFormat.Xml;
    request.XmlSerializer.ContentType = "application/vnd.com.cisco.ise.identity.endpoint.1.0+xml; charset=utf-8";
var response = client.Execute(request);

当我提交代码时,我收到"不支持的媒体类型"错误。头文件取自思科的SDK。我已经通过curl、SharePoint和SC Orchestrator实现了这一点。

我认为在请求的XML组合中有一个错误,但我找不到它。

任何想法?

使用RestSharp在思科ISE上注册端点

您需要在header中添加内容类型,它与接受的内容类型相同:

请求。Method = Method. get;request.AddHeader("接受",应用程序/vnd.com.cisco.ise.identity.guestuser.2.0 + xml");request.AddHeader("内容类型","应用程序/vnd.com.cisco.ise.identity.guestuser.2.0 + xml");