cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
479
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: dan turner on 02-02-2010 03:35:56 PM
 
Hey guys,

I'm just trying to execute a query using EMAPI...
 
heres the Code...
 
        ExtQuery = "<query>/n";
                ExtQuery += "<appInfo> /n";
                ExtQuery += "<appID>admin</appID> /n";
                ExtQuery += "<appCertificate>p1tBas!c</appCertificate> /n";
                ExtQuery += "</appInfo> /n";
                ExtQuery += "<userDevicesQuery> /n";
                ExtQuery += "<userID>" + UserID + "</userID> /n";
                ExtQuery += "</userDevicesQuery> </query>/n";        
 

 
   HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://192.168.200.15/emservice/EMServiceServlet");
 

   req.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
            req.ContentType = "application/x-www-form-urlencoded";
            req.Method = "POST";
            req.KeepAlive = true; 
 
            Stream s = req.GetRequestStream();
            s.Write(System.Text.Encoding.ASCII.GetBytes(ExtQuery), 0, ExtQuery.Length);
            s.Close();
            WebResponse resp = req.GetResponse();
            StreamReader sr = new StreamReader(resp.GetResponseStream());
            string XMLResult = sr.ReadToEnd();
 
Im getting an Error 500 Internal server error...
 
does anyone have any suggestions? if i browse to the URL i also get an error 500 page.
 
Dan


 

Subject: RE: Extension Mobility Query...
Replied by: Michel Shuqair on 03-02-2010 11:59:09 AM
Hi,
 
I've seen this error before. For us the solution was to enable Extension Mobility on BOTH publisher and subscriber. If it was enabled for only one of them it gave http 500 error.
 
Hope this helps.
 
 

Subject: RE: Extension Mobility Query...
Replied by: dan turner on 04-02-2010 10:52:18 AM
very odd...
 
there must be multiple causes for this then!!!
 
i only have a publisher.. its a vmware test machine...
 
anyhoo i think it was my headers...
 
In case anyone is curious I got it working with this:
 

   ExtQuery = "xml=<query>";
                ExtQuery += "<appInfo> <appID>admin</appID> <appCertificate>p1tBas!c</appCertificate> </appInfo>";
                ExtQuery += "<userDevicesQuery> <userID>"+UserID+"</userID> </userDevicesQuery>";
                ExtQuery += "</query>";

 

       HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://x.x.x.x:8080/emservice/EMServiceServlet");
 
            req.Accept = "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2";
            req.ContentType = "application/x-www-form-urlencoded";
            req.Method = "POST";
            req.KeepAlive = true;
 
            Stream s = req.GetRequestStream();
            s.Write(System.Text.Encoding.ASCII.GetBytes(ExtQuery), 0, ExtQuery.Length);
            s.Close();
            WebResponse resp = req.GetResponse();
            StreamReader sr = new StreamReader(resp.GetResponseStream());
            string XMLResult = sr.ReadToEnd();

Subject: RE: Extension Mobility Query...
Replied by: dan turner on 04-02-2010 10:55:17 AM
Sorry Michael, I meant to say thanks for the suggestion too!!!
 
this forum seems awfully quiet so I wasn't really expecting a response.
 
Dan

Subject: RE: Extension Mobility Query...
Replied by: dan dan on 12-03-2010 03:35:00 PM
may you say how to work this services on IP phones??
userid ,machine id e.g values how to take??

Subject: RE: Extension Mobility Query...
Replied by: Axel Schemberg on 16-09-2010 10:35:48 AM
Hi Dan,
 
I ran into the same problem with CUCM 6.1.2 (on VMWare too).
While my C# doesn't work a simple HTML works.
 
Did you find any solution?
 
Kind regards
 
Axel

Subject: RE: Extension Mobility Query...
Replied by: Axel Schemberg on 24-09-2010 10:47:32 AM
Hi Dan,
 
I think I found "your" fault ... it isn't really yours, it is more to the developer or those who write the documentation.
1. Although you might think we are talking XML, no, we don't. That means no xml header like <?xml version=1.0> etc. Just use simple string.
2. urlencode the xml based em api call "urlencode("<query>...some content ...</query>");"
3. prepend an xml= (not urlencode!) to encoded xml (see step 2).
4. use HTTP header "Content-Type: application/x-www-form-urlencoded"
 
that should work. In your example you miss step 3 I think.
 
Kind reagards
 
Axel

Subject: RE: Extension Mobility Query...
Replied by: Sascha Monteiro on 22-11-2010 08:49:07 PM
cool, I couldn't find the  "Content-Type: application/x-www-form-urlencoded" in the API doco, very odd that this is used...
I had to run wireshark to trace the message from the EMApi example to see the header..
a REST service would have been nice, like CUPI, Cisco introduced too many different webservices 😉
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links