I was trying to invoke a json parsed python function on IBM cloudant action function. It give me error message saying that I cant import cloudant. Following is the action function in python that I have created on cloudant:
"""IBM Cloud Function that gets all reviews for a dealership
Returns:
List: List of reviews for the given dealership
"""
from cloudant.client import Cloudant
from cloudant.error import CloudantException
import requests
def main(param_dict):
"""Main Function
Args:
param_dict (Dict): input paramater
Returns:
_type_: _description_ TODO
"""
try:
client = Cloudant.iam(
account_name=param_dict["COUCH_USERNAME"],
api_key=param_dict["IAM_API_KEY"],
connect=True,
)
print(f"Databases: {client.all_dbs()}")
except CloudantException as cloudant_exception:
print("unable to connect")
return {"error": cloudant_exception}
except (requests.exceptions.RequestException, ConnectionResetError) as err:
print("connection error")
return {"error": err}
return {"dbs": client.all_dbs()}
I tried to upload requirements.txt as zip file but did not work.