07-23-2016 09:32 PM
Hi !
I am trying to change agent state using REST API. I am using C# as a programming language.
here is the code that I wrote :
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("https://url:8445/finesse/api/User/agent2"));
request.Credentials = new NetworkCredential("agent2", "12345");request.Method = "POST";
request.ContentType = "application/xml";
// request.Accept = "application/xml";XElement redmineRequestXML =
new XElement("User",
new XElement("state", "READY"),
new XElement("extension", "3010")
);byte[] bytes = Encoding.UTF8.GetBytes(redmineRequestXML.ToString());
request.ContentLength = bytes.Length;
using (Stream putStream = request.GetRequestStream())
{
putStream.Write(bytes, 0, bytes.Length);
}// Log the response from Redmine RESTful service
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
MessageBox.Show(reader.ReadToEnd());
}
And I am getting this error :
The remote server returned an error: (405) Method Not
so please any idea could help solving this issue ?
Solved! Go to Solution.
07-24-2016 05:18 AM
after 2 days I figured out that the issue is to replace this line :
request.Method = "POST";
by this line :
request.Method = "PUT";
07-24-2016 05:18 AM
after 2 days I figured out that the issue is to replace this line :
request.Method = "POST";
by this line :
request.Method = "PUT";
07-24-2016 10:12 PM
Correct. The Change Agent State API is a HTTP Method PUT because it is an update versus a create (which is what POST is). This is documented in the developer guide: https://developer.cisco.com/media/finesseDevGuide2/CFIN_RF_C1D2CCD7_00_change-agent-state.html
Thanx,
Denise
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide