
In processing the response, we can look at the StatusCode to make sure the request succeeded and then use the parsed json in the Data parameter to extract complex information from the response. In the above example, the request is fairly simple, so we can skip creating a WebRequest and instead use the Client.GetJSON helper to GET json from a specific url. WebResponse for dealing with responses.WebRequest for defining complex requests.There are 3 primary components in VBA-Web: GetJSON Exampleįunction GetDirections(Origin As String, Destination As String ) As String ' Create a WebClient for executing requests ' and set a base url that all requests will be appended to Dim MapsClient As New WebClient MapsClient.BaseUrl = "" ' Use GetJSON helper to execute simple request and work with response Dim Resource As String Dim Response As WebResponse Resource = "directions/json?" & _ "origin=" & Origin & _ "&destination=" & Destination & _ "&sensor=false" Set Response = MapsClient.GetJSON(Resource) ' => GET ProcessDirections Response End Function Public Sub ProcessDirections(Response As WebResponse) If Response.StatusCode = WebStatusCode.Ok Then Dim Route As Dictionary Set Route = Response.Data( "routes" )( 1 )( "legs" )( 1 ) Debug.Print "It will take " & Route( "duration" )( "text" ) & _ " to travel " & Route( "distance" )( "text" ) & _ " from " & Route( "start_address" ) & _ " to " & Route( "end_address" ) Else Debug.Print "Error: " & Response.Content End If End Sub The following examples demonstrate using the Google Maps API to get directions between two locations. Support for custom request and response formats.For proxy environments, Client.EnabledAutoProxy = True will automatically load proxy settings.Authentication support is built-in, with suppory for HTTP Basic, OAuth 1.0, OAuth 2.0, Windows, Digest, Google, and more.XML support is still possible on Windows, follow these instructions to use a custom formatter.
SERVICENOW REST API VBA FOR MAC
Note: XML support has been temporarily removed from VBA-Web while parser issues for Mac are resolved.
SERVICENOW REST API VBA UPGRADE
To upgrade from Excel-REST to VBA-Web, follow the Upgrading Guide
SERVICENOW REST API VBA WINDOWS
VBA-Web (formerly Excel-REST) makes working with complex webservices and APIs easy with VBA on Windows and Mac.
