I want to write a client to an API that's described via Swagger. I'm new to Python but not to programming.
The API definition is here: https://app.swaggerhub.com/apis/calpolyud/Reeher/1
I used the codegen tools to generate a Python client and have been tinkering with it. No matter which generated class I attempt to invoke, I always get this error:
TypeError: 'NoneType' object is not iterable
Here's my sample code:
from __future__ import print_function import time import swagger_client from swagger_client.rest import ApiException from pprint import pprint # create an instance of the API class swagger_client.Configuration.apikey = 'somethingsecret' api_instance = swagger_client.ContactReportApi() activity_id = 'R176954627' # str | activityID of contact report try: # Find a contact report by activityID response = api_instance. get_contact_report(activity_id) except ApiException as e: print("Exception when calling ContactReportApi->get_contact_report: %s\n" % e)
Here's the stacktrace.
Traceback (most recent call last): File ".\api_client.py", line 15, in api_instance.get_contact_report(activity_id) File "V:\UD\Shared\Data Systems\Projects\Reeher API\swagger_client\api\contact_report_api.py", line 66, in get_contact_report (data) = self.get_contact_report_with_http_info(activity_id, **kwargs) # noqa: E501 File "V:\UD\Shared\Data Systems\Projects\Reeher API\swagger_client\api\contact_report_api.py", line 140, in get_contact_report_with_http_info collection_formats=collection_formats) File "V:\UD\Shared\Data Systems\Projects\Reeher API\swagger_client\api_client.py", line 333, in call_api _preload_content, _request_timeout) File "V:\UD\Shared\Data Systems\Projects\Reeher API\swagger_client\api_client.py", line 122, in __call_api collection_formats)) File "V:\UD\Shared\Data Systems\Projects\Reeher API\swagger_client\api_client.py", line 416, in parameters_to_tuples for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 TypeError: 'NoneType' object is not iterable
I can roll my own client and teach myself more Python, but I was expecting to benefit from the Swagger ecosystem. Am I missing something simple here?