Getting *** TypeError: expected string or bytes-like object on the link_token_create function call
neerajshivam23 opened this issue · 0 comments
neerajshivam23 commented
For this request body I am getting type error, any luck where I may be doing wrong, curl is working as expected only on SDK call it fails.
request = LinkTokenCreateRequest(
products=[Products("auth")],
client_name="Test",
language="en",
country_codes=[CountryCode("US")], # type: ignore
user=LinkTokenCreateRequestUser(client_user_id=str(user_id)), )
configuration = plaid.Configuration(
host=get_plaid_api_host(),
api_key={
"clientId": config.settings.plaid_client_id,
"secret": config.settings.plaid_secret,
"plaidVersion": "2020-09-14",
},
)
api_client = plaid.ApiClient(configuration)
client = plaid_api.PlaidApi(api_client)
client.link_token_create(request)
# Error:
# *** TypeError: expected string or bytes-like object
Stack Trace:
client.link_token_create(request)
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/plaid/api/plaid_api.py", line 19730, in link_token_create
return self.link_token_create_endpoint.call_with_http_info(**kwargs)
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/plaid/api_client.py", line 879, in call_with_http_info
return self.api_client.call_api(
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/plaid/api_client.py", line 421, in call_api
return self.__call_api(resource_path, method,
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/plaid/api_client.py", line 198, in __call_api
response_data = self.request(
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/plaid/api_client.py", line 467, in request
return self.rest_client.POST(url,
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/plaid/rest.py", line 270, in POST
return self.request("POST", url,
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/plaid/rest.py", line 156, in request
r = self.pool_manager.request(
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/urllib3/request.py", line 78, in request
return self.request_encode_body(
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/urllib3/request.py", line 170, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/urllib3/poolmanager.py", line 376, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 714, in urlopen
httplib_response = self._make_request(
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 415, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/urllib3/connection.py", line 244, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1283, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1324, in _send_request
self.putheader(hdr, value)
File "/Users/neeraj/Desktop/Work/sparc-api/.venv/lib/python3.10/site-packages/urllib3/connection.py", line 224, in putheader
_HTTPConnection.putheader(self, header, *values)
File "/opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1260, in putheader
if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object