What can you learn here?

  • sing cRest
  • Advanced capabilities
  • Building new libraries

Accessing the cRest class directly get it now

Up till now we’ve been looking at the modules in the Rest to Excel library as the integration point into the cRest class. This covers how to use the cRest class directly and covers its capabilities and code.

Try it out first ?

These are enhancements to Data Manipulation Classes so they have been included in cDataSet.xlsm, which is downloadable from Download Complete Projects.

cRest properties

  • jObjects As Collection
    • Returns a collection of cJobject, one for each query executed since the object was initialized
  • jObject() As cJobject.
    • Returns the latest cJobject to be deserialized. In other words, the response to the last query executed.
  • erType() As erRestType.
    • Returns enum erRestType to indicate the type of query, erSingleQuery or erQueryPerRow being executed.
  • response() As String
    • Returns the raw response received from the last query executed
  • encodedUri() As String
    • Returns the URI and query that was sent in encoded http format
  • queryhCell() As cCell
    • Returns a cCell Class representing the column header being used to generated erQueryPerRow  queries.
  • queryString(p As String)
    • sets the queryString that will be encoded into the encodedUri
  • restUrlStem(p As String)
    • Sets the Rest Url that will be encoded into encodedUri
  • dSet() As cDataSet
    • returns the cDataSet that represents the abstraction of the worksheet being processed

How to use cRest

Here’s a ‘google patent’ example of using the cRest class directly, and execute a query in one line of code

Public Sub testcrdirect()
Dim cr As New cRest, dset As New cDataSet
cr.init("responseData.results", erSingleQuery, , , _
dset.populateData(wholeSheet("patent"), , "patent", , , , True), , _
"https://ajax.googleapis.com/ajax/services/search/patent?v=1.0&rsz=8&q=", _
, False).execute "excel"
End Sub

Here’s the code for cRest

Summary

You may find it necessary to use this class directly, but most functionality can be accessed through the Rest to Excel library In the meantime  you can also submit anything you want considered for publication on this site (for example if you add interesting Rest calls to the restLibrary) to our forum. Now let’s look Combining multiple rest queries