Connection string for web api

I want to use web api as a connection string in UiPath process mining connector.is it possible ?

sample connection string : ‘driver={mvscript}; mv-enable=true; filename=https://website.com/script/process_mining/cases.php; hasheader=True; delim=,; quote="; encoding=UTF8’

By using python script methods , I am able to get data from web api and connect to input_table, UiPath documentation : example-creating-python-script , Not sure if any other shortest method for this execution, I am using this as solution for now

connection string as below.

script.py ( python script to upload into workspace )

#!/usr/bin/python
import csv
import sys
import requests

def debug(message):
    sys.stderr.write(message)

# Read the CSV header. This is used so that the script will output the fields
# in the same order that they were read in. This step is optional.
column_order = [];
with open(sys.argv[1]) as csv_file:
    reader = csv.reader(csv_file, delimiter=';')
    column_order = next(reader)

# Process the input file
with open(sys.argv[1]) as csv_file:
    reader = csv.DictReader(csv_file, delimiter=';')

    # Construct the output writer.
    writer = csv.DictWriter(
        sys.stdout,
        column_order,
        delimiter=';',
        restval='',
        quoting=csv.QUOTE_ALL
    )
    writer.writeheader()

    #Fetch json data from api
    response = requests.get("https://yourwebsite.com/api/")
    if response.status_code==200:
        cases = response.json()
        for case in cases :
            case_id = case['Case_ID']
            amount = case['Amount']
            writer.writerow({'Case_ID': case_id, 'Amount': amount})
        # Exit indicating success
        exit(0)
    else:
        # Exit indicating error
        print("Unable to fetch data")
        exit(1)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.