Skip to content

Work with web services (Salesforce, Twitter, and pretty much everything on the internet) directly from Excel

Notifications You must be signed in to change notification settings

jordanzhang/Excel-REST

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Excel-REST: Excel REST Client

It seems like everything has a REST webservice these days and there is no reason to leave Excel out of the fun. Also, as of V0.2 there's async support! (Example workbook coming in a jiffy)

(API design based heavily on the awesome RestSharp)

Example:

Sub TwitterSearch()
	Dim twitterClient As New RestClient
	twitterClient.baseUrl = "https://api.twitter.com/{ApiVersion}/"
	
	' Setup OAuth1 authentication (there are also authenticators for HTTP Basic and OAuth2)
	Set twitterClient.Authenticator = RestModule.OAuth1( _
	    ConsumerKey:="your-consumer-key", _
	    ConsumerSecret:="your-consumer-secret", _
	    Token:="your-token", _
	    TokenSecret:="your-token-secret" _
	)
	
	Dim search As New RestRequest
	search.Resource = "search.{format}"
	
	' Set the request format
	' Replaces the format keyword in the Resource, sets the content/type, and parses the results
	search.Format = json
	
	' Add a parameter to the request
	' (Added as a querystring for GET calls and added to the request body for everything else)
	search.AddParameter "q", "Excel"
	
	' Add a url segment
	' Replaces any {tags} in the BaseUrl or Resource
	search.AddUrlSegment "ApiVersion", "1"
	
	' Execute the request (synchronous and asynchronous(!) methods available)
	Call twitterClient.ExecuteAsync(search, "HandleSearchResults")
End Sub

' Callback for async call that takes in the response from the request
Sub HandleSearchResults(response As RestResponse)
	Debug.Print _
		"This was handled asynchronously: " & _
		response.StatusCode & " (" & response.StatusDescription & "): " _
		& response.Content
End Sub

About

Work with web services (Salesforce, Twitter, and pretty much everything on the internet) directly from Excel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published