The following is a Python function to ingest data from the Datagran API Action.

Python code

import requests
import time

def run_task(Cedula_ID):

  headers = {
      'content-type': 'application/json',
      'api-key': '028q66ccf9a70cJfBV7qdce5ddwQ01K9S4J69494M9cc0Qf17qc8d9dC2139ec6e9PweCcfaqH4Zqe3e501fC6JKQ72deb85045sKe6QB5f',
  }

  json_data = {
      'params': {
          'Cedula': '33280877',
      },
  }

  response = requests.post('<https://api.v2.datagran.io/v2/sql_api_operator/614c7fe257838794b6655a90>', headers=headers, json=json_data)
  return response.json()['bg_task_id']

def wait_task(bg_task_id):
  headers = {
      'content-type': 'application/json',
      'api-key': '028q66ccf9a70cJfBV7qdce5ddwQ01K9S4J69494M9cc0Qf17qc8d9dC2139ec6e9PweCcfaqH4Zqe3e501fC6JKQ72deb85045sKe6QB5f',
  }

  params = (
      ('bg_task_id', bg_task_id),
  )

  csv = ""
  while True:
    time.sleep(5)
    response = requests.get('<https://api.v2.datagran.io/v2/sql_api_operator/614c7fe257838794b6655a90>', headers=headers, params=params)    
    if response.json()['status'] == 'COMPLETED':
      for row in response.json()['rows']:
        csv += ','.join(row)
        csv += '\\n'
      return csv
    elif response.json()['status'] == 'ERROR':
      return None
        

bg_task_id = run_task('22493478')
# print(bg_task_id)
csv_content = wait_task(bg_task_id)
print(csv_content)