IBM / python-sdk-core

The python-sdk-core repository contains core functionality required by Python code generated by the IBM OpenAPI SDK Generator.
Apache License 2.0
20 stars 27 forks source link

Return Null #173

Closed Ofabiojvalentim closed 1 year ago

Ofabiojvalentim commented 1 year ago

Using python 3.11 on IBM Cloud Functions

from ibmcloudant.cloudant_v1 import CloudantV1 from ibm_cloud_sdk_core.authenticators import IAMAuthenticator from http.client import HTTPConnection

def main(param_dict):

HTTPConnection.debuglevel = 1

try:
    authenticator = IAMAuthenticator(param_dict["IAM_API_KEY"])
    client = CloudantV1(authenticator=authenticator)
    client.set_service_url(param_dict["COUCH_URL"])

    if "dealerId" in param_dict:
        dealer_id = param_dict["dealerId"]

        try:
            response = client.post_find(
                db="reviews",
                selector={
                    "dealership": {
                        "$eq": dealer_id
                    }
                }
            )
            reviews = response.result["docs"]

            return {'body': reviews}

        except requests.exceptions.RequestException as err:
            print("something bad happens")
            return {"error": err}
    else:
        return {"Info":"Empty Parameters"}

except requests.exceptions.RequestException as err:
    print("erro de conexão")
    return {"error": err}

When I Make a http request, passing param_dict dealerId = 15, body returns [], but everything is processed ok on IBM CF

padamstx commented 1 year ago

You'll need to be more specific about what you are trying to do, what you expect to have happen and what you are actually observing. Which operation are you trying to invoke? which SDK?

padamstx commented 1 year ago

Closing due to lack of a response