Calling REST API via MS Access / VBA

I have an MS Access application that is hosted on a Remote Server.  One of the features I need to add is the ability to dial phone numbers and have looked at several solutions (as some of you know).  One of the solutions seems ideal as it will dial the required number and then call the users desk-phone (a common practice).  The service provider has a RESET API toolkit available, which looks ideal - but sadly, I have never worked with REST.  

So my question is this.  Will I be able to make a REST API call via VBA/Access as well as pull in the results  (connection time, engaged etc).
Andy BrownDeveloperAsked:
Who is Participating?
 
Jim Dettman (Microsoft MVP/ EE MVE)Connect With a Mentor President / OwnerCommented:
<<Will I be able to make a REST API call via VBA/Access as well as pull in the results  (connection time, engaged etc).>>

 Yes.   REST is nothing more than exchanging strings using HTTP protocol using GET and POST statements.

 Jack Leach has a nice overview here:

https://dymeng.com/web-work-with-vba/

 
 More specifically, you set a reference to the Microsoft XML doc lib, and this gives you what you need.   Below is some example code of doing some CC processing with REST.  Take a look at the last half of that.   All your doing is sending a string and then getting a string in response, which you then parse.

Jim.

 ' Capture the CC

                  ' Set the correct URL
                  'strPostURL = "https://test.authorize.net/gateway/transact.dll"
110               strPostURL = "https://secure.authorize.net/gateway/transact.dll"
                  'strPostURL = "https://developer.authorize.net/tools/paramdump/index.php"

120               strPostSting = ""
125        strPostSting = strPostSting & "x_login=" & URLEncode(strAPILogin) & "&"
126       strPostSting = strPostSting & "x_tran_key=" & URLEncode(strTransactionKey) & "&"
                  'For debugging.
                  'strPostSting = strPostSting & "x_test_request=" & URLEncode("TRUE") & "&"
130               strPostSting = strPostSting & "x_version=" & URLEncode("3.1") & "&"
140               strPostSting = strPostSting & "x_delim_data=" & URLEncode("TRUE") & "&"
150               strPostSting = strPostSting & "x_delim_char=" & URLEncode("|") & "&"
160               strPostSting = strPostSting & "x_relay_response=" & URLEncode("FALSE") & "&"
170               strPostSting = strPostSting & "x_email_customer=" & URLEncode("FALSE") & "&"

180               strPostSting = strPostSting & "x_type=" & URLEncode("PRIOR_AUTH_CAPTURE") & "&"
190               strPostSting = strPostSting & "x_trans_id=" & URLEncode(rs!CCTransactionID) & "&"

                  ' Additional fields can be added here as outlined in the AIM integration
                  ' guide at: http://developer.authorize.net
200               strPostSting = left(strPostSting, Len(strPostSting) - 1)

                  ' We use xmlHTTP to submit the input values and record the response
                  Dim objRequest As New MSXML2.XMLHTTP
210               objRequest.Open "POST", strPostURL, False
220               objRequest.Send strPostSting
230               strPostResponse = objRequest.responseText
                  'Debug.Print strPostResponse
240               Set objRequest = Nothing

                  ' the response string is broken into an array using the specified delimiting character
250               arrResponse = Split(strPostResponse, "|", -1)

260               If arrResponse(0) = 1 Then

Open in new window

0
 
D GConnect With a Mentor Commented:
Habe you tried this one?
vba-tools.github.io/VBA-Web/
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Andy BrownDeveloperAuthor Commented:
That's a great start - thank you.
0
 
John TsioumprisSoftware & Systems EngineerCommented:
Can you clarify it a bit...you want the Access to call a phone number ?
0
 
Jim Dettman (Microsoft MVP/ EE MVE)Connect With a Mentor President / OwnerCommented:
and in regards to what DG posted, this is the one everyone seems to like to use, although Jack had some comments (and fixes for it) in another one of his blog posts:

https://github.com/VBA-tools/VBA-Web

 But if you don't need JSON (which is just a way of formatting a response string, akin to XML), then you can stick with the simple setup I posted in my last comment.

Jim.
0
 
Andy BrownDeveloperAuthor Commented:
That looks ideal guys - thank you - quite excited about trying it out.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.