You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to send a simple PDF file using the Lob Python SDK, but I'm running into errors. The key issue seems to be that the file param of LetterEditable will only accept a Python str value, which doesn't allow for in-memory PDFs.
It also does not upload local files like the API documents say it should. Uploading raw HTML works, but we need to upload PDF files.
Ideally I would like to pass an in-memory file, e.g. bytes or io.BytesIO. Here's what I see when I try to pass that:
lob_python.exceptions.ApiTypeError: Invalid type for variable 'file'. Required value type is str and passed type was bytes at ['file']
That error is being generated in lob_python, letter_editable.py:362:
self.file = file
because on line 120:
'file': (str,), # noqa: E501
and this is enforced via __setitem__ in ModelNormal and set_attribute in OpenApiModel.
Suggestion: create a file_upload_type parameter, that would accept 'file-like-stream', 'html', 'url', etc. Then allow each of those in the file parameter.
I'm using python 3.12.3 and lob_python====5.1.3.
I've already brought this up with Lob support, who suggested I open this issue.
The text was updated successfully, but these errors were encountered:
Hi, I'm trying to send a simple PDF file using the Lob Python SDK, but I'm running into errors. The key issue seems to be that the
file
param of LetterEditable will only accept a Pythonstr
value, which doesn't allow for in-memory PDFs.It also does not upload local files like the API documents say it should. Uploading raw HTML works, but we need to upload PDF files.
Ideally I would like to pass an in-memory file, e.g. bytes or io.BytesIO. Here's what I see when I try to pass that:
That error is being generated in lob_python, letter_editable.py:362:
because on line 120:
and this is enforced via
__setitem__
inModelNormal
andset_attribute
inOpenApiModel
.Notes:
file_upload_type
parameter, that would accept 'file-like-stream', 'html', 'url', etc. Then allow each of those in the file parameter.The text was updated successfully, but these errors were encountered: