Overview
The Fizz API is based on a RESTful architecture, so talking to Coolfront Mobile is as easy as browsing web pages, and submitting forms. The beauty of REST (Representational State Transfer) is its consistency. Each URI is a resource, and each resource supports a standard set of HTTP verbs.
The sections below gloss over some of the nitty gritty, like authentication with tokens and pagination of data that are explained in more detail on the other pages of this site.
Collections of Data
For collections of data, you can do a GET request to fetch a list of records, or a POST request to add a new record to the collection. For example, the URI for customers is /fizz/customers.
Task | Verb | URI | XML |
---|---|---|---|
fetch all customers | GET | /fizz/customers |
<customers> <customer> <id>1</id> <first-name>John</first-name> <phone-1>5551234567</phone-1> ... </customer> <customer> <id>2</id> <first-name>Mary</first-name> <phone-1>5559990000</phone-1> ... </customer> </customers> |
add a new customer | POST | /fizz/customers |
<customer> <first-name>Jamie</first-name> <phone-1>5552224444</phone-1> ... </customer> |
Fizz will not add (or update) multiple records in a single request. One record per request, please.
Single Records
For a single record, you can do a GET request to fetch the data, or a PUT request to update it.
Task | Verb | URI | Data |
---|---|---|---|
fetch one customer | GET | /fizz/customers/1 |
<customer> <id>1</id> <first-name>John</first-name> <phone-1>5551234567</phone-1> ... </customer> |
update a customer's phone number | PUT | /fizz/customers/1 |
<customer> <phone-1>5556667777</phone-1> </customer> |
If your tool/language doesn't support the PUT method, don't worry, you can just do a POST and pass in the _method param with a value of PUT. (Fizz does not support the DELETE verb for removing data; instead you can mark things as inactive or cancelled.)
Examples
As discussed on the authentication page, a security token must be passed with every request. Here's an example written with everyone's favorite tool...curl!!! (We've omitted the full urls for the sake of brevity.)
#update the first-name of customer 23 curl -H "Content-Type:text/xml" -X PUT -d " <?xml version=\"1.0\" encoding=\"UTF-8\"?> <customer> <first-name>Mary</first-name> </customer> " /fizz/customers/23.xml?token=1234 #or update the same customer with xml that is saved in customer.xml curl -X PUT -d @customer.xml /fizz/customers/23.xml?token=1234 #create a new customer curl -X POST -d @customer.xml /fizz/customers.xml?token=1234 #add a new address to an existing customer curl -X POST -d @address.xml /fizz/customers/45/addresses.xml?token=1234
For more details on the fields and data types take a look at the API reference.