L

Wednesday, November 9th, 2022 5:22 PM

Can we invoke the Collibra DQ REST API using Python?

Collibra DQ prospective customer sent me the question: “Can we invoke the Collibra DQ REST API using Python?”
Answer: I sent the prospect my sample Python REST API code:

login_uri = 'https://'+conf.url+'/auth/signin'
export_uri = '/v2/get-exports'
import_uri = '/v2/run-import'
api_url = 'https://'+conf.url+'/v3/'
login_url = 'https://'+conf.url+'/v2/login'
r = requests
s = None
headers = None

def login():
    urllib3.disable_warnings()
    token = 'Bearer ' + str(json.loads(r.post(url=login_uri,
                                              headers={'Content-Type': 'application/json'},
                                              data='{"username": "'+conf.username+'", "password": "'+conf.password+'","iss": "'+conf.tenant+'"}',
                                              verify=False).content)['token'])
    print(token)
    header = {"Content-Type": "application/json","Authorization": token}
    headers = header
    s = requests.session()
    s.headers.update(header)
    #s.post(
    #    url=login_url,
    #    headers={'Content-Type': 'application/x-www-form-urlencoded'},
    #    data='username='+conf.username+'&password='+conf.password+'&iss='+conf.tenant
    #)

    #s.headers
    #s.cookies
    end_point = api_url + 'dataset-defs/template'
    print(end_point)
    return s.get(end_point)

I met with them, and helped them debug the Python, and then they tested it and got this working:

No Responses!
Loading...