VBS Connection for using WinHttp.WinHttpRequest

Talk with others about developing applications for Switchvox

Moderators: bmdhacks, dpodolsky, tristand, jwitt, joshuas

VBS Connection for using WinHttp.WinHttpRequest

Postby Pog » Wed Feb 02, 2011 9:54 pm

Gurus,

I am using VBS scripting within a CRM product. I am using something like below to get a response from the server:
Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
..blah..
objWinHttp.Open "GET", myPBX_IPAddress
..blah..
objWinHttp.Send (myXML)
..blah..
GetDataFromURL = objWinHttp.ResponseText
..blah..
Do something with Response.... blah....

I get a response back from the request, but it's a web page that is requesting that I log in. The problem with this is that this is in VBS app and does not really have a web interface exposed where I can present the web page to the user. I tried to open IE outside my application and logging in because I saw it drops cookies, but still get the same login-request from my call above.

So the simple noobie question I am asking is: "Is there a xml request or something that I can pass to login with the appropriate credentials" without bringing up a login web page?

XML I am passing in my initial request is something like this:
<request method="switchvox.call"><parameters> <dial_first>4040</dial_first> <dial_second>14803175484</dial_second> <dial_as_account_id>4044</dial_as_account_id> <caller_id_name>Autodialer</caller_id_name> <ignore_user_api_settings>1</ignore_user_api_settings> </parameters> </request>
Pog
Newsterisk
 
Posts: 5
Joined: Wed Feb 02, 2011 9:09 pm

Re: VBS Connection for using WinHttp.WinHttpRequest

Postby david55 » Thu Feb 03, 2011 5:08 am

Switchvox is a Digium commercial product, I believe. You should be able to use Digium commercial support channels.

If I were doing CTI in that evironment, I would use AMI, not XML. I'm not sure that there is XML support in the open source Asterisk.
david55
Moves Like Spencer
 
Posts: 7695
Joined: Fri Sep 26, 2008 5:03 am

Re: VBS Connection for using WinHttp.WinHttpRequest

Postby malcolmd » Thu Feb 03, 2011 12:11 pm

There isn't but the Switchvox Extend API is XML-friendly. I'm moving this post to the correct forum.
Malcolm Davenport
Digium, Inc. | Senior Product Manager
malcolmd
Moves Like Spencer
 
Posts: 2192
Joined: Wed Aug 03, 2005 3:53 pm
Location: Huntsville, AL, US

Re: VBS Connection for using WinHttp.WinHttpRequest

Postby Pog » Thu Feb 03, 2011 2:52 pm

Which forum should I go to to further discuss this?
Pog
Newsterisk
 
Posts: 5
Joined: Wed Feb 02, 2011 9:09 pm

Re: VBS Connection for using WinHttp.WinHttpRequest

Postby david55 » Fri Feb 04, 2011 5:24 am

The one the thread is now in, which appears to be Switchvox | Switchvox Developers
david55
Moves Like Spencer
 
Posts: 7695
Joined: Fri Sep 26, 2008 5:03 am

Re: VBS Connection for using WinHttp.WinHttpRequest

Postby dpodolsky » Mon Feb 07, 2011 7:46 pm

Hopefully this is an easy solution.

In your pseudo code you wrote :
objWinHttp.Open "GET", myPBX_IPAddress


This should be a POST and the address you want to post to is : myPBX_IPAddress/xml
The trailing /xml on the server address is how you interact with the server via the XML api. If you don't include the XML you will be interacting with our html interface and thus get the login page.

Also, you still need to login to the XML interface so make sure you pass the proper login information via digest authentication to the XML api.

Here is a write up that details all this found in our documentation wiki:
http://developers.digium.com/switchvox/ ... _Interface
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Re: VBS Connection for using WinHttp.WinHttpRequest

Postby Pog » Tue Feb 08, 2011 12:23 pm

Ahhh.... Good eye. It was the /xml on the end like you stated that I was missing. Now getting "401: Authorization Required."

So next question:
1) Do I have to pass the encoded admin password through the URL or can I include it as part of the xml request? If so what does the format look like.
2) Do I have to use the Admin user? I would like to pass the users ext and the users pass, without depending on the cookie. Is that possible?
Pog
Newsterisk
 
Posts: 5
Joined: Wed Feb 02, 2011 9:09 pm

Re: VBS Connection for using WinHttp.WinHttpRequest

Postby dpodolsky » Tue Feb 08, 2011 12:42 pm

1. Make sure you read through this documentation that I posted earlier. It will give you information on how to connection and authenticate:
http://developers.digium.com/switchvox/ ... _Interface

You are getting a 401 because you need to use digest authentication for the API. Digest auth is a common auth method that most libraries have support for (more info in the link).

2. If you don't want to use the admin then you can authenticate and make calls as a user. Look at the switchvox.users.call method : http://developers.digium.com/switchvox/ ... users.call. When making calls as a user you need to be aware that all the outgoing call rules and api rules for that user are enforce. So if the user can't dial long distance numbers then the API won't let them either.
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Re: VBS Connection for using WinHttp.WinHttpRequest

Postby Pog » Tue Feb 08, 2011 2:53 pm

You guys ROCK !!! Working like a champ.
Awesome response time for a web forum.
Yes you can quote me on that.
Pog
Newsterisk
 
Posts: 5
Joined: Wed Feb 02, 2011 9:09 pm


Return to Switchvox Developers

Who is online

Users browsing this forum: No registered users and 1 guest