Creating & Updating Data

  Date Updated: August 2014

There are two request methods you can use to add and edit entities in the application: HTTP PUT and POST.

HTTP POST

Use the POST method to add a new entity to the application. For example, you might use the POST method to add a customer contact to a business. Each POST will create another contact entity for the business.

HTTP PUT

Use the PUT method to update an existing entity in the application. For example, to update a customer contact entity with new information you would use the PUT method.

Response

A successful call will return:

A HTTP status code of

  • 201 for POST calls
  • 204 for PUT calls

A Location response header param with the entity uri. Eg. For a contact entity


HeaderValue
Location:{domain}/businesses/{business_uid}/contacts/{contact_uid}

When to use?

Should I use PUT or POST?

If you want to:

  • add a new entity, use the HTTP POST method.
  • edit a entity that already exists, use the HTTP PUT method. This will update the content of the existing entity.
  • add a entity even if it already exists, use the POST method. This is known as a non-idempotent method. Repeating the POST call will add the entity again.

Please note: When updating an existing entity, you will need to add the unique entity identifier uid to the end of the entities URI

For example, to create or update a contact:

  • POST to the entities uri:
    {domain}/businesses/{business_uid}/contacts
  • PUT to the entity uri:
    {domain}/businesses/{business_uid}/contacts/{contact_uid}