cURL Example

You can change the price of the newly inserted widget using the PUT verb and send back the object you received from the insert, with a different price, for example:
cURL is a popular command-line utility to interact with various network protocols, including HTTP and HTTPS. It is pre-installed on the Mac. You must install it on Windows. You interact with a REST API, such as API Server, using cURL. The following are a few examples of using cURL.
For more information about cURL, see the cURL website.
In this article:
Log In to API Creator
When you log in to API Creator, the authentication provider obtains the authentication token for the API user. If you have specified the 
built-in authentication
 provider or a JavaScript authentication provider as the authentication provider for your API, you can send your credentials to the server by issuing the following command:
curl -d '{"username":"demo","password":"Password1"}' -H "Content-type: application/json" -X POST
The following response is expected:
{ "apikey": "5b35864f4724ea3e1278c3cd4dc06087", "expiration": "2015-11-06T01:26:06.826Z", "lastLoginTs": "2015-11-05T01:24:52.943Z", "lastLoginIP": "", "email": "[email protected]" }
 value is the value that the following examples use for 
. The 
 value is the value of the authentication token that you need to make calls. 
Retrieve Some Data
The following request includes an HTTP header named 
 that identifies and authenticates the call:
curl -H "Authorization: CALiveAPICreator APIKEY:1"
You can create your own authentication tokens and give them the permissions that you require. 
https://server.<organization name>.com/rest
 is the base URI. The URI is dependent on how you access 
CA Live API Creator
. The 
 value is the name of your account. The 
 value is the name of your API. The 
 value is the API version that you want to access. The 
 value is the name of your resource, which can be a table or a resource that is defined for one or more table.
The following response assumes that there is only one widget in the database or that the authentication token has access to read only one widget. A response similar to the following is expected:
[ { "@metadata": { "href": "", "checksum": "R:2b26c827f961d5db" }, "ident": 1002, "name": "Demo widget", "price": 123.45 } ]
 object contains the information 
CA Live API Creator
 requires for context. You will normally send it as part of the object when interacting with the API.
Filter and Sort
GET provides filter and sort. URL-encode special characters.The following code snippet shows examples of a filter and a sort:
# Filter: name like '%Hammer%'curl -H "Authorization: CALiveAPICreator APIKEY:1" # Sort: name desccurl -H "Authorization: CALiveAPICreator APIKEY:1"
These examples use regular filters and sorts. By default, you can use regular filters and sorts. If you have turned off regular filters and sorts in your API, you can use named filters and sorts.
 For more information:
Insert an Object
For more information about GET, see GET.
To insert a new widget, use the POST verb:
curl -H "Authorization: CALiveAPICreator APIKEY:1" -H "Content-type: application/json" -d '{"name": "My new widget", "price": 199.99}' -X POST
For more information about the POST verb, see POST.
 header is required. The data (-d) is quoted with a single quote, allowing the use of double quotes in the JSON (the JSON standard requires this format).
The following response is expected:
{ "statusCode": 201, "txsummary": [ { "@metadata": { "href": "", "resource": "widgets", "verb": "INSERT", "checksum": "R:71830068badf0977" }, "ident": 1008, "name": "My new widget", "price": 199.99 } ] }
The 201 status code (which is the same as the HTTP response code, but it is nice to also have it in the response) indicates that the insert was successful.
 object is an array of all the objects that have been modified by this transaction. In this case, it's only the newly inserted object, but if any other objects had been inserted, updated or deleted as a result of logic rules, they would show up in the transaction summary.
Update an Object
You can change the price of the newly inserted widget using the PUT verb and send back the object you received from the insert, with a different price, for example:
curl -H "Authorization: CALiveAPICreator APIKEY:1" -H "Content-type: application/json" -d '{"@metadata": { "href": "", "checksum": "R:71830068badf0977"}, "price": 150}' -X PUT
The following response is expected:
{ "statusCode": 200, "txsummary": [ { "@metadata": { "href": "", "resource": "widgets", "verb": "UPDATE", "checksum": "R:a164cfeba97c19db" }, "ident": 1008, "name": "My new widget", "price": 150 } ] }
This response assumes that no other object was affected by this transaction. The status code of 200 indicates that the update was successful.
Delete an Object
This example uses the DELETE verb, the primary key of the object (1008) on the URI, and the current checksum of the object, which we got from the update example. You can override the checksum, bypass 
CA Live API Creator
's optimistic locking, and delete the object regardless of whether someone else has modified it since we last got it by giving it a value of override.
curl -H "Authorization: CALiveAPICreator APIKEY:1" -X DELETE
The following response is expected:
{ "statusCode": 200, "txsummary": [ { "@metadata": { "href": "", "resource": "widgets", "verb": "DELETE" }, "name": "My new widget", "price": 150 } ] }
The transaction summary can contain other objects affected by this transaction.