cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1565
Views
1
Helpful
2
Replies

Finesse REST API

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 ?

1 Accepted Solution

Accepted Solutions

after 2 days I figured out that the issue is to replace this line :

request.Method = "POST";

by this line :

request.Method = "PUT";

View solution in original post

2 Replies 2

after 2 days I figured out that the issue is to replace this line :

request.Method = "POST";

by this line :

request.Method = "PUT";

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