Queries & Reports API: Insert or update a record with auditing
API endpoints for queries, reports, and record operations
Insert or update a record with auditing
Use this API to insert a record or update fields values for a record in a table and includes record locks and audit record creation.
This API can be run for authorised tables. Run getTablesAuthorisedForImport) to get a list of these tables.
Audit records created in these updates are marked as external.
Multiple records can be updated within the JSON payload provided they belong to the same table.
All records in the JSON payload are individually locked during the update.
Supplementary SWAGGER documentation is available here: api.catch-e.com/docs/#/Import%20%2F%20Export/upsert
Dependent Records
You can use a UUID placeholder in the import files to manage data where there are child records that have a key field dependency,
E.g. .
Visit the Dependent Records page for the details of how to use this feature.
Permissions
To run this API, the nominated 'web-services' role needs to be given permission.
If you are not actively using the API, leave the permission off for better security.
Go to Roles / Apis and check on Record:Upsert.
HTTP Method
Use the HTTP Method 'POST' for consuming this web service.
URL Examples
The table you are updating forms part of the URL path. E.g. api.staging.catch-e.com/gb/record/upsert/table_name
https://api.catch-e.com/gb/record/upsert/{table_name}Parameters
Body (JSON payload)
API Examples
This example is for two contracts being updated within the same request, the first has updates one field, the second updates two fields.
https://api.catch-e.com/gb/record/upsert/fm_contracts[ { "contract_id": 100000, "colour": "Blue" }, { "contract_id": 100001, "colour": "White", "radio_pin": "777" }]This example is to create a new contract (insert record). It will create a new Contract and set the colour to blue. All other fields will use default values or will be blank.
https://api.catch-e.com/gb/record/upsert/fm_contracts[ { "contract_id": "", "colour": "Blue" }]204 - No Content
- (BLANK) — The request was successful request. No response is required (BLANK)
400 - Bad Request
- "detail": "JSON decoding error: Underflow or the modes mismatch" — The JSON content is mis-configured e.g. a missing right brace (curly bracket '}') will trigger this error. "title": "Bad Request",
403 - Forbidden
- "detail": "Forbidden" — You do not have permissions for this request.
422 - Unprocessable Entity
- "detail": "Failed Validation" — The table used in the API uses a Unique Key. The required fields that make up the Unique Key have not all been passed. See Table Data for documented Unique Key tables and their required fields. "records": { "missingMandatoryColumns": "Missing mandatory columns: supplierid, cardnumber"
- "detail": "Failed Validation" — The table used in the API does not have a singularis not authorised. See getTablesAuthorisedForImport for available tables. "table_name": { "noRecordFound": "Table is not authorised for import or is invalid"
423 - Locked
- "detail": "Locked" — The record that the update was being run for was locked. Try again later. "Record already locked by user: {user_login}"
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html", "title": "Locked", "status": 423, "detail": "Locked"}| If one of the records in the JSON Body is already being edited, the entire batch will fail and show this message. | |
Web service Gb Queries exportQuery
Execute a query known by queryid and return the resultset as XML.This web service executes a query stored in the table qtqueries, and can include queries with derived fields.
Note: If you don't need to use any derived fields in your query, use the Print a report query API.
Contact Catch-e Support if you need assistance with the set-up.
Input Fields
Warning: The limit clause will only work with simple queries, e.g. it won't work with queries involving UNIONs. If in doubt, please contact Catch-e Support.
Input URL Example
https://yourname.catch-e.net.au/services/gb/queries/exportQuery?query_id=100001Output Fields
Output Example
100000
Holden
…
100001
Ford
…
Error Codes
Error Output
CATCHEERRORUNKNOWNQUERY
Troubleshooting
Tip: Visit the main Troubleshooting page for a list of all the available problem-solving tips.
403 Error
If you are using the exportQuery function in your web site, Catch-e will need to whitelist the IP address you are using so this function is allowed.
Web service Gb Queries query
Warning: This web service has been deprecated and is no longer supported by Catch-e.
You must use Print a report query instead and contact Catch-e Support if you need assistance with the set-up.
Execute a specified query, and return the resultset as Text(csv), XML, or Office(xls).
The query can include Derived Fields.
Multiple queries#multiple-queries-url-example) are supported with the resultset limited to XML only.
URL Encoding Tool
SQL queries are to be encoded according to rfc3986 - example see http://www.php.net/manual/en/function.rawurlencode.php
For your convenience there is an encode / decode tool located at https://yourname.catch-e.net.au/utils/urlencode.phpo
Input Fields
Input URL Example 1
SELECT contract_id FROM fm_contracts LIMIT 10To run the above query you would use:
https://yourname.catch-e.net.au/services/gb/queries/query?login=######&password=######&query=SELECT%20contract_id%20FROM%20fm_contracts%20LIMIT%2010Input URL Example 2
SELECT t1.attachment_id, t1.table_name, t1.record_id, COUNT(t2.attachment_id) AS number_of_attachmentsFROM gb_attachments AS t1LEFT JOIN gb_attachments AS t2 ON t2.table_name = t1.table_name AND t2.record_id = t1.record_id AND t2.status_flag != 'deleted'WHERE t1.status_flag != 'deleted'GROUP BY t1.attachment_idHAVING number_of_attachments > 0To run the above query you would use:
https://yourname.catch-e.net.au/services/gb/queries/query?login=######&password=######&query=SELECT%20t1.attachment_id%2C%20t1.table_name%2C%20t1.record_id%2C%20COUNT%28t2.attachment_id%29%20AS%20number_of_attachments%0AFROM%20gb_attachments%20AS%20t1%0ALEFT%20JOIN%20gb_attachments%20AS%20t2%20ON%20t2.table_name%20%3D%20t1.table_name%20AND%20t2.record_id%20%3D%20t1.record_id%20AND%20t2.status_flag%20%21%3D%20%27deleted%27%0AWHERE%20t1.status_flag%20%21%3D%20%27deleted%27%0AGROUP%20BY%20t1.attachment_id%0AHAVING%20number_of_attachments%20%3E%200Output Fields
Output Example
100000
Holden
…
100001
Ford
…
Output Example When Query Returns Empty Resultset
1 0Multiple Queries URL Example
Each query must be separated by a semicolon (;) followed by a neIf Nothing Foundwline character.2 Queries:https://yourname.catch-e.net.au/services/gb/queries/query?login=######&password=######&query=SELECT%20contract_id%20FROM%20fm_contracts%20LIMIT%202%3B%0ASELECT%20vmrs_code%20FROM%20fm_vmrs_codes%20LIMIT%202%3B3 Queries:https://yourname.catch-e.net.au/services/gb/queries/query?login=######&password=######&query=SELECT%20contract_id%20FROM%20fm_contracts%20LIMIT%2010;%0D%0ASELECT%20quote_id%20FROM%20qt_quotes%20LIMIT%2010;%0D%0ASELECT%20%2A%20FROM%20fm_clients%20LIMIT%201Multiple Query Output Example (2 Queries)
100000 100001 4WDC A/FError Codes
Error Output
CATCHEERRORMISSINGQUERY
GetCountries
Allows you to extract the list of Countries for use in other APIs that use "country_id:" in their payload. These include CreateDrivers), updateDriversList) or updateDriver).
The use of "country_id:" is optional.
Permissions
If you want to use this API in your system, enable Countries:Get.
- Go to System Roles and select the 'web_services' role
- Navigate to the Roles / APIs tab
- Find the Countries:Get permission and check it's check box
HTTP Method
Use the HTTP Method 'GET' for consuming this web service.
URL Examples
For a list of Countries:
https://api.demo.catch-e.com/gb/countriesInput Fields (Body)
Wildcard % operator notes:
If you are using "Postman" app, with the wildcard operator, the search string of either %ab% or %ba%, will give this response:
"field_name": {"isEmpty": "Value is required and can't be empty"}.If you need to search either %ab% or %ba%, please use %25ab%25 or %25ba%25 as required to return results as expected.
Input Fields (JSON)
https://api.catch-e.com/gb/countries[ { "name": "Australia", "iso_code_2": "", "iso_code_3": "", "page": "1" "page_size":"25" }]Successful Response Example
{ "_links": { "self": { "href": "https://api.staging.catch-e.com/gb/countries/?name=Australia&page=1&page_size=25" }, "first": { "href": "https://api.staging.catch-e.com/gb/countries/?name=Australia&page_size=25" }, "last": { "href": "https://api.staging.catch-e.com/gb/countries/?name=Australia&page=1&page_size=25" } }, "_embedded": { "gb_countries": [ { "country_id": "7015503456999836108", "name": "Australia", "iso_code_2": "AU", "iso_code_3": "AUS", "_links": { "self": { "href": "https://api.staging.catch-e.com/gb/countries/7015503456999836108" } } } ] }, "page_count": 1, "page_size": 25, "total_items": 1, "page": 1}Error Response Details
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html", "title": "Unauthorized", "status": 401, "detail": "Unauthorized"}| You have not authenticated before running this API or The token_timeout of the current session has passed. You need to authenticate again. |
| 403 - Forbidden | | |
{ "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html", "title": "Forbidden", "status": 403, "detail": "Forbidden"}| You do not have permissions for this request. Go to System Roles and enter 'web_services' Navigate to the Roles / APIs tab to make sure the permission you need to run this API is checked. |
| 422 - Unprocessable Entity | |
| | No validations are in place due to the wildcard option. |