Accessing data objects through the external API - kwantu/platformconfiguration GitHub Wiki

back

Accessing data objects through the external API

This page describes how to access a feed of data objects through an external API service.

A generic service to make a feed of data objects from an app and a given community available externally.

The following steps are needed to set this up:

  1. Define the api_key in the mysql table mobile1_8.etl_external_api
  2. In this record, specifiy the setIds of all the data objects to be included. They can currently only come from one application and one community per key. They are specified as a comma delimited set with no spaces or breaks.
  3. Set the etl_type=dataObject
  4. If this is the first time that the service runs, set the index_created to 0, else it will keep deleting and re-indexing the database for this service.

The call to access the service is as follows

https://<hostname>/exist/rest/db/kwantu-resource/etl/external/api.xql
?api_key=<api key defined in mysql>
&password=<password defined in mysql>
&bookmark=<value of the most recently returned bookmark>
&limit=<Number of records/documents to return>

// example
https://kwantu.support/exist/rest/db/kwantu-resource/etl/external/api.xql?api_key=ntipCompanyCapabilities&password=ntip&bookmark=53038-g1AAAAFreJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____s5IYGCQV8ahLUgCSSfZQpVIs-JQ6gJTGQ5VK78GnNAGktB5maj8epXksQJKhAUgBVc8HuzeRoPIFEOX7wcpjCCo_AFF-H-yYboLKH0CUg90uUZYFAHiNYpA&limit=10

The format returned is as follows

A successfull call will look like this

{
  "message" : "Rest service called successfully",
  "recordsReturned" : 10,
  "errorCode" : "OK",
  "bookmark" : "53645-g1AAAAFreJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____s5IYGCRD8ahLUgCSSfZQpVJT8Cl1ACmNhyqVfo1PaQJIaT3M1Et4lOaxAEmGBiAFVD0f7N61BJUvgCjfD1beTFD5AYjy-2B34ws1iPIHEOVgt0uszwIA0c5j8A",
  "pending" : 3811,
  "docs" : [ .... ],
  "isError" : false
}
  1. message is the message describing the status of extracting the search records
  2. recordsReturned is the actual number of documents returned
  3. errorCode is the reference code to an error encountered
  4. bookmark is the pointer that must be supplied the next time the search is called to retrieve the next block of records
  5. pending gives an indication of the number of potential documents still remaining. No attention can be given to the exact number, because it includes an estimate of all (including other) documents that have been changed since the bookmark number. Use this merely to determine that there is nothing to do if the number returned is 0
  6. docs is the array of documents retrieved. Each document is a json object 7 isError is a flag to test if there was an errror or not.

If an error was encountered it will return this

{
  "message" : "Invalid password",
  "recordsReturned" : 0,
  "bookmark" : "",
  "docs" : null,
  "isError" : true
}
⚠️ **GitHub.com Fallback** ⚠️