REST requests generally contain the following elements, some of which may be omitted for certain calls:
- HTTP request type (POST, GET, etc.)
- HTTP headers
- HTTP content
Their application to the InterFAX REST API is detailed below.
Operation properties are submitted as key/value pairs in the command line. Keys are documented for each operation documented here. For example, to call POST /outbound/fax with all its properties populated, place an HTTP POST call like this (for reading convenience the query string has not been url-encoded):
Note that the query string in the URL above needs to be url-encoded to avoid prohibited characters (such as spaces). Once encoded it will look like this:
HTTP request types
HTTP calls may be of type HTTP GET, HTTP POST, or HTTP DELETE, depending on the specific operation being called. This reference describes which call type each operation supports.
Some operations may require content to reside within the HTTP headers. This is the case for authentication, for example, where a correctly-populated Authorization header must be present.
Some operations may require content to reside within the HTTP call itself. For example, sending a fax requires the document you wish to fax to be placed in an HTTP POST call as MIME, and certain headers to be present in the call. For example:
POST /outbound/faxes?destination=+12125554584 HTTP/1.1 Host: rest.interfax.net Content-Length: 1352 Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== Content-Type: multipart/form-data; boundary=--------------------------+-7d03135102b8 -----------------------------7d03135102b8 Content-Disposition: form-data; name="file"; filename="C:\whatever\fax.txt" Content-Type: text/plain Hello there
Forcing a response format
By default, the REST response format is JSON, however, additional formats are available. The way to force a certain response format is by setting an Accept HTTP header in the request, like:
GET /outbound/faxes/85456521 Host: rest.interfax.net Accept: application/xml
|“Accept” Header||Response Format|
|Accept: text/html||Human-readable HTML|