Calling API's with HTTP Requests
How to talk to web API's using HTTP requests
Last updated
How to talk to web API's using HTTP requests
Last updated
The Language of the Web
You are probably already familiar with the Hyper Text Transfer Protocol (HTTP) as that is how your web browser talks to web servers over the internet to show you web pages. Your browser sends an http request to a web server, that responds with a http response with html data that will be rendered in your browser for you to read.
This same technology can also be used to request and serve data, that better suited for programs to read. Instead of serving html they respond with data, typically json or xml. These are call Application Programming Interfaces or API's.
XLConnect has a built in HTTP client that allows Excel to call these API's with minimal technical friction.
In the Javascript Studio, this code will execute an HTTP request and display the data.
Copy and paste it into a new Javascript Studio window and hit F5 to execute it.
This code grabs data (click here to see the raw data) about Star Wars characters. Double click the results
element to drill down to the actual characters.
Please not this uses the HTTP module GET method that handles
An HTTP request has three major parts:
The Unique Resource Identifier URI (sometimes also called URL for Locator)
The Headers
The Content
API's have not really converged to a uniform way of using these elements to make it work, so be prepared to use all of them.
You will have seen many uri's in your life, to make sure you understand exactly what each part means, below is a short summary.
Headers are key-value properties that be sent and received, this allows both client and server to add properties to a request. Xero for instance requires that every request has a property xero-tenant-id
to indicate for which tenant the request is meant for. Another often used property is
The Content of a web request is the actua thing you wat to send and/ or recieve, in today's