Data Services - writing data

The URLs supported for reading data from each entity on the Indicia warehouse can also be used to update existing records and add new records to the database. This is achieved by posting a submission to the URL. Because the submission can contain records for multiple entities and it embeds the name of the entity(s) you are posting into, it is also possible to post submissions to the URL site root + /index.php/services/data/save. This URL is the preferred approach of sending submissions.

The submission content itself must be posted to the warehouse URL using a POST value called submission which is in the format required for an Indicia submission. Submissions must have the following information provided. All these values can be provided in the GET or POST information sent to the URL:

  • auth_token - the write authentication token
  • nonce - the write authentication token’s nonce

The following values can also be passed but are optional:

  • user_id - the ID of the warehouse user, if known. Allows all records to be associated with their user account.
  • transaction_id - a unique ID for the transaction generated by the calling code. This will be returned in all responses from the warehouse allowing the caller to use the save web services asynchronously. For example, this might be a row ID in a grid when using JavaScript and AJAX to save records as the grid is edited. If a validation failure occurs, then the transaction_id is returned in the response allowing the row with the error to be found and highlighted.
  • cache_updates - set to “off” to prevent updates to the cache_* tables as a result of an update. This improves performance where the field being updated does not need to be reflected in the cache tables.

The URL will parse the submission to determine the records to insert or update in the database, validate the proposed changes, then either perform the changes to the database or will return the validation errors.