cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
664
Views
0
Helpful
1
Replies
Highlighted
Contributor

UCCE 10.5 API - AgentSkill Change

Hey All.

When i try to update skills on an agent thru the API (on a c# code) on a ucce 10.5 I keep getting error 415 (unsupported media type).

This failure is only comming on my post calls - so i can without problem get the skills on my agent, but i cannot change them (Via Post).

If I try to change them thrue PostMan it works fine (Same username/password  and same XML).

I am using the c# extension RestSharp

Here is my cSharp code:

System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate (object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

  System.Net.ServicePointManager.Expect100Continue = true;

  ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; 

  var client = new RestClient();

  client.BaseUrl = new Uri(adminUrl);

  client.Authenticator = new HttpBasicAuthenticator(adminUid, adminPwd);

  var request = new RestRequest();

  request.Resource = "/unifiedconfig/config/operation";

  request.Method = Method.POST;

request.AddHeader("Content-Type", "application/xml");

request.AddHeader("Cache-Control", "no-cache");

request.AddHeader("Accept", "application/xml");

request.Parameters.Clear();

request.RequestFormat = RestSharp.DataFormat.Xml;

request.AddBody(xml);

IRestResponse response = client.Execute(request);

And here is the XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<operation>

<operationType>update</operationType>

<refURLs>

<refURL>/unifiedconfig/config/agent/9017</refURL>

</refURLs>

<changeSet>

<agent>

<skillGroupsRemoved>

<skillGroup>

<refURL>/unifiedconfig/config/skillgroup/5738</refURL>

</skillGroup>

</skillGroupsRemoved>

</agent>

</changeSet>

</operation>

The username and password is an Supervisor and the agent is in the team.

Has anyone had this problem ?

1 REPLY 1
Highlighted
Beginner

Hi Thomas,

At present you have:

request.AddHeader("Content-Type", "application/xml"); 

My understanding is that you should replace this with:

request.ContentType = "application/xml";

C.