Skip to main content
Version: 2.3

2.15 API Push Service

The API Push Service is a generic method for importing data into the Data Context Hub Graph Builder Service (GBS) system, in addition to the Data Pumps. If a dedicated Data Pump is not available for the source, this API endpoint can still be used for import.

API Endpoint

/api/importer/pushEntitiesToRepository

  • ?entitySaveOption=
    • Merge: Delete all entity members that are not in the current data set, insert new and updates existing ones.
    • InsertOnly: Inserts only new entity members.
    • UpdateOnly: Updates only existing entity members.
    • CleanThenInsert: Cleans all data and inserts entity members.
    • Delete: Deletes entity data.
    • PreservingMerge: Inserts new entity members and updates existing ones.
  • &processAfterPush=
    • true: Process the imported data to the neo4j graph.
    • false: Does not process the imported data to the neo4j graph.
  • &distinct=
    • true: Remove all duplicates (based on the Business key).
    • false: No check for duplicates.
  • &debugMode=false

Data Structure for the Push

Provide the data to be imported as a JSON with the following structure:

{
"Entity_ID_1": [
{
"Property_1": "Value",
"Property_2": "Value",
"Property_3": "Value"
},
{
"Property_1": "Value",
"Property_2": "Value",
"Property_3": "Value"
}
],
"Entity_ID_2": [
{
"Property_4": "Value",
"Property_5": "Value",
"Property_6": "Value"
},
{
"Property_4": "Value",
"Property_5": "Value",
"Property_6": "Value"
}
]
}
  • Different Entity Id's are organized as a Json Array of Json Objects
  • Property values as Key/Value pairs inside of the Json Object
    • one Property has to be unique as the Business key

Hint: Cou can export a data Push template of the created Entity in GBS → Target Entities

Code Example

This Python Source Code shows a minimal example how to use the Push API.

  • Authentication on Keycloak
def get_Authorization() -> str:
client_secret = ""
url = keycloak_url + "/realms/explore-develop/protocol/openid-connect/token"

payload = "client_id=cbse&grant_type=client_credentials&client_secret=" + client_secret
headers = {'Content-Type': 'application/x-www-form-urlencoded'}

try:
response = requests.post(url, headers=headers, data=payload)
except requests.exceptions.ConnectionError as e:
print("Connection refused. No access token retrieved. Abort. ({0})".format(e))
quit()

response_json = json.loads(response.text)
return "Bearer " + response_json["access_token"]
  • Push data
def push_entities_request(token: str, data: str):
api_url = base_url + "/api/importer/pushEntitiesToRepository?entitySaveOption=cleanThenInsert&processAfterPush=false&distinct=true&debugMode=false"
headers = {'Content-Type':'application/json', 'Authorization':token}
response = requests.post(api_url, data=data, headers=headers)
print(response.json())
  • Main
def main():      
json_file = open("C:\\example.json", "rb").read()

try:
token = get_Authorization()
except Exception as e:
print("Exception: {0}".format(e))
quit()

push_entities_request(token, json_file)