Pushing Data
Pushing data into Coolfront Mobile using Fizz is just a matter of POSTing XML data. The fields supported are detailed on the API reference, but here are some quick examples to get you started.
Adding vs Updating
There are two types of request that change the data in Coolfront Mobile. The first is a POST request which is used to add a new record. When you POST a new record the URI must be for a collection of objects. For example, if we wanted to add a new customer we could POST this XML:
<customer> <first-name>Mary</first-name> </customer>...to this URI...
/fizz/customers.xml?token=1234
The other request used to change data is the PUT request. A PUT request will update an existing record. When you make a PUT request the URI must be for a single of object. For example, if we wanted to update the last-name of a customer (with the id of 9), we would POST this XML:
<customer> <last-name>Contrary</last-name> </customer>...to this URI...
/fizz/customers/9.xml?token=1234
Technical Side Note: There is some debate in the web community about PUT requests. The official definition says that a PUT request should be a complete representation of the data, and it should replace the existing resource. However, in practice, the API for many sites (including Fizz) take the more pragmatic approach of allowing partial updates in a PUT request. Partial updates really belong to the much less well known (and rarely used) PATCH verb.
So just remember that with Fizz a PUT acts like a PATCH , which means that you don't have to send back all the fields of a record, but you can if you want to. At the very least you need to send the fields that changed.
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.