Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
andy_steel #1
Member since Mar 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: sending GET,PUT,POST to Cisco Finesse over BOSH ?
I'm writing prototype code in C# that connects to Finesse using this toolkit. I can currently establish the BOSH connection and I'm getting Dialog + User messages coming through in realtime.

I'm confused about how to now send GET/SET/POST messages to Finesse so that I can go into ready, not ready, make calls, set call variables, drop calls, etc.

Do I send these commands over the BOSH connection using a Matrix.Xmpp.Client.Message and calling Send() ?
If so then can you provide an example GET, PUT and POST that works?

Or do I send these commands using seperate standard HTTP functions within .NET framework ?

An example would be:
PUT: /finesse/api/User/1111126 HTTP/1.1
request body: <User><state>NOT_READY</state><reasonCodeId>5</reasonCodeId></User>

many thanks,
Andy
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Finesse has an HTTP and and XMPP API.
All commands should be able for both APIs
When you are using XMPP already then I would suggest to stay with the XMPP API and send all commands over XMPP.

You send them over XmppClient.Send(yourpacket).
The XMPP XML commands should be in the API documents of Finesse.
When you have any specific questions on how to build a Finesse packet and send it with MatriX let us know and point also to the docs.

Alex
Avatar
andy_steel #3
Member since Mar 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
At present I'm sending the requests seperate from the BOSH connection, but i'd like to use BOSH for both requests and events.

Here's an example that i'm using to set the agent READY.

  1. string m_strUsername = "1111126";
  2. string m_strPassword = "password";
  3. string m_strAuth = Convert.ToBase64String(Encoding.ASCII.GetBytes(m_strUsername + ":" + m_strPassword));
  4.  
  5. // setup WebClient
  6. System.Net.WebClient m_wc = new WebClient();
  7. m_wc.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  8. m_wc.Headers.Add("Authorization", string.Format("Basic {0}", m_strAuth));
  9. m_wc.Headers.Add("Content-Type", "application/xml");
  10.  
  11. // perform the PUT request
  12. byte[] dataBytes = Encoding.UTF8.GetBytes("<User><state>READY</state></User>");
  13. m_wc.UploadData("http://jnofin105a/finesse/api/User/1111126", "PUT", dataBytes);

So I know this works and i've done other requests including GET, PUT and POST.

How would I then get this to work over the BOSH connection specifically for Finesse ?

My concern is how to convey the following details:
 a) The URL for the request
 b) Whether it's a PUT, GET or POST
 c) The request body which usually contains XML

I can see from the network traffic logs generated by the Finesse client, it seems to send requests to "/gadgets/makeRequest" using POST. It'll then pass the request data as seperate request parameters, as below shows. First word is the parameter, the rest of the line is the data.

url    http%3A%2F%2Flocalhost%3A8080%2Ffinesse%2Fapi%2FDialog%2F16784381
httpMethod    PUT
headers    requestId%3De3f5b877-3f6d-4e5b-8a86-35d96290107c%26Content-Type%3Dapplication%252Fxml%26Authorization%3DBasic%2520MTExMTEyNjpiZWxsMg%253D%253D%26locale%3Den_US
postData    %3CDialog%3E%3CtargetMediaAddress%3E105503%3C%2FtargetMediaAddress%3E%3CrequestedAction%3EDROP%3C%2FrequestedAction%3E%3C%2FDialog%3E
authz   
st   
contentType    TEXT
numEntries    3
getSummaries    false
signOwner    true
signViewer    true
gadget    http%3A%2F%2Flocalhost%3A8080%2Fdesktop%2Fgadgets%2FCallControl.jsp
container    default
bypassSpecCache    0
getFullHeaders    true

I don't know whether Finesse BOSH apis support requests of this type?
This post was edited on 2016-03-04, 17:34 by Alex.
Avatar
ssteiner #4
Member since Jan 2016 · 26 posts · Location: Switzerland
Group memberships: Members
Show profile · Link to this post
Finesse has two APIs.. one is for notifications over a BOSH/ XMPP channel (by the way.. how are you doing BOSH? I thought that was a browser thing.. I'm doing native XMPP with this lib), the other one is a regular REST API.

All the requests to the REST API (sections "Cisco Finess Desktop APIs", "Cisco Finesse Configuration APIs", and "Cisco Finesse Serviceability APIs") require an approach like you posted. If you look at the environment and tools section of the developer guide.. it also states you need two tools.. poster allows you to operate against the rest api (so log in agent, change agent state, etc.), and pidgin that gets notifications via xmpp.

It's probably best explained in Figure 1 on the dev guide.. there's two components on Finesse, the Finesse Tomcat (webserver, for rest calls like the one you posted), and the cisco finesse notification service which you can talk to using bosh or xmpp.

The Finesse client uses the same REST API.. if you look at your captured data.. it makes a PUT to http://finesseserver:8080/finesse/api/Dialog/dialogid.. that's some kind of call update as per the Dialog APIs section of the dev guide.
Avatar
andy_steel #5
Member since Mar 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Hi,

I'm using BOSH (I believe) by setting the following properties:

  1. static XmppClient m_xmppClient = new XmppClient();
  2. m_xmppClient.Transport = Matrix.Net.Transport.Bosh;
  3. m_xmppClient.Uri = new System.Uri("http://myserver:7071/http-bind/");

It's working fine for me, and I understand having to use the two APIs. I really wanted confirmation that this was how it's supposed to work and there wasn't something I was missing.

There was a statement, below, in the Cisco Developer guide which worried me at first but I can't say I've come across anything that's conflicting or cause for concern at the moment. All my code works well, irrespective of whether Finesse is running or not.

You cannot be signed in to Pidgin at the same time you are signed in to Finesse as the XMPP event feed is disrupted
This post was edited on 2016-03-07, 10:58 by Alex.
Avatar
Alex #6
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
BOSH is a HTTP transport layer for XMPP. It was develop for constrained clients which can talk only HTTP, which are usually web browsers. But BOSH can also be used on Desktop client. There are some enterprise IT environments where internet access is only available over HTTP there it makes sense. But whenever you can use sockets then I suggest to use sockets and not BOSH.

@ssteiner: Thanks for the clarification. If there are public docs for the Finesse API you can post them here and I will also take a closer look at it.

Alex
Avatar
ssteiner #7
Member since Jan 2016 · 26 posts · Location: Switzerland
Group memberships: Members
Show profile · Link to this post
@andy_steel: in my experience, having both pidging and the finesse desktop running works fine. But now I'm doing server to server, so I have an agent whose only purpose is to get me access to XMPP.. and then I subscribe for notifications for any other agents I'm interested in. But before I had things set up this way, I had pidging running to see what is happening if I'm doing stuff with the agent.

What you cannot do is log in twice.. you cannot use the rest api to log in the agent... but you can interact with the agent just fine (e.g. changing status).

@Alex: The dev guide is public - it can be found here: https://developer.cisco.com/site/finesse/documents/dev-gui…
Avatar
bavly500@gmail.com #8
Member since Aug 2017 · 2 posts · Location: Egypt
Group memberships: Members
Show profile · Link to this post
In reply to post #5
Hi @andy

i am tying to use  BOSH/ XMPP channel

like this code

  1. private XmppClientConnection xmpp;
  2.  
  3. xmpp = new XmppClientConnection();
  4.  
  5. xmpp.Server = domain;//"dcloud.cisco.com";
  6.  
  7. xmpp.SocketConnectionType = agsXMPP.net.SocketConnectionType.Bosh;
  8.  
  9. xmpp.ConnectServer = "http://x.dcloud.cisco.com:7071/http-bind/";
  10.  
  11. xmpp.Username = agentID;//"1072";
  12. xmpp.Password = password;//"123456";
  13.  
  14. xmpp.Port = 5222;
  15. xmpp.Resource = "cisco";
  16. xmpp.AutoRoster = true;
  17. xmpp.AutoAgents = false;
  18. xmpp.AutoPresence = true;
  19. xmpp.AutoResolveConnectServer = true;
  20. xmpp.OnXmppConnectionStateChanged += Xmpp_OnXmppConnectionStateChanged;
  21. xmpp.OnError += Xmpp_OnError;
  22. xmpp.OnAuthError += Xmpp_OnAuthError;
  23. xmpp.OnWriteXml += new XmlHandler(client_OnWriteXml);
  24. //xmpp.OnMessage += Xmpp_OnMessage;
  25. xmpp.OnReadXml += new XmlHandler(client_OnReadXml);
  26. xmpp.OnRosterStart += Xmpp_OnRosterStart;
  27. xmpp.OnRosterEnd += Xmpp_OnRosterEnd;
  28. xmpp.OnSocketError += Xmpp_OnSocketError;
  29. xmpp.OnStreamError += Xmpp_OnStreamError;
  30. xmpp.Open();

but i always get this error after binding when i am read xml , It is connected and authenticated successfully after that in binding i got that error anyone face this error ? 

  1. <?xml version="1.0"?>
  2. -<iq id="agsXMPP_1" type="error" to="x.dcloud.cisco.com/1e2ee691"
  3. from="dcloud.cisco.com" xmlns="jabber:client">
  4. -<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
  5. <resource>cisco</resource>
  6. </bind>
  7. -<error type="modify" code="400">
  8. <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
  9. </error>
  10. </iq>

      
Thanks
This post was edited 3 times, last on 2017-09-07, 12:04 by bavly500@gmail.com.
Avatar
bavly500@gmail.com #9
Member since Aug 2017 · 2 posts · Location: Egypt
Group memberships: Members
Show profile · Link to this post
I solved the problem thank you the problem is in

the binding not same for
x.dcloud.cisco.com/1e2ee691"
& from="dcloud.cisco.com

changed the to be the same

also

 * use default sockets instead of Bosh connection
             * recommended from xmpp link
             * https://forum.ag-software.net/thread/1888-Finesse-Presence…
             *
            //xmpp.SocketConnectionType = agsXMPP.net.SocketConnectionType.Bosh;
            //xmpp.ConnectServer = "http://finesse1.dcloud.cisco.com:7071/http-bind/finesse/api/User/1072";
            // UserName + "@" + FinesseServer + "123456"  + "/http-bind";
            //"http://finesse1.dcloud.cisco.com:7443/http-bind/ ;

            */

thanks all
This post was edited on 2017-09-10, 11:07 by bavly500@gmail.com.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS