We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(if you think this is solvable through the SDK alone, happy to submit a PR, in that instance any guidance would be awesome) To reproduce:
from writerai import Writer from dotenv import load_dotenv import os load_dotenv() WRITER_API_KEY = os.getenv("WRITER_API_KEY") WRITER_APP_ID = os.getenv("WRITER_APP_ID") if not WRITER_API_KEY or not WRITER_APP_ID: raise ValueError("missing env vars") client = Writer(api_key=WRITER_API_KEY) file = client.files.upload( content=b'raw file contents', content_disposition='attachment; filename*=utf-8''test.txt', content_type='application/txt' )
Error message:
--------------------------------------------------------------------------- BadRequestError Traceback (most recent call last) Cell In[1], [line 14](vscode-notebook-cell:?execution_count=1&line=14) [10](vscode-notebook-cell:?execution_count=1&line=10) raise ValueError("missing env vars") [12](vscode-notebook-cell:?execution_count=1&line=12) client = Writer(api_key=WRITER_API_KEY) ---> [14](vscode-notebook-cell:?execution_count=1&line=14) file = client.files.upload( [15](vscode-notebook-cell:?execution_count=1&line=15) content=b'raw file contents', [16](vscode-notebook-cell:?execution_count=1&line=16) content_disposition='attachment; filename*=utf-8''test.txt', [17](vscode-notebook-cell:?execution_count=1&line=17) content_type='application/txt' [18](vscode-notebook-cell:?execution_count=1&line=18) ) File c:\Notes\writer\.venv\lib\site-packages\writerai\resources\files.py:291, in FilesResource.upload(self, content, content_disposition, content_type, extra_headers, extra_query, extra_body, timeout) [274](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:274) """ [275](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:275) Upload file [276](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:276) (...) [284](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:284) timeout: Override the client-level default timeout for this request, in seconds [285](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:285) """ [286](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:286) extra_headers = { [287](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:287) "Content-Disposition": content_disposition, [288](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:288) "Content-Type": content_type, [289](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:289) **(extra_headers or {}), [290](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:290) } --> [291](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:291) return self._post( [292](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:292) "/v1/files", [293](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:293) options=make_request_options( [294](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:294) extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout [295](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:295) ), [296](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:296) binary_request=content, [297](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:297) cast_to=File, [298](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/resources/files.py:298) ) File c:\Notes\writer\.venv\lib\site-packages\writerai\_base_client.py:1275, in SyncAPIClient.post(self, path, cast_to, body, options, files, binary_request, stream, stream_cls) [1255](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1255) def post( [1256](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1256) self, [1257](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1257) path: str, (...) [1265](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1265) stream_cls: type[_StreamT] | None = None, [1266](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1266) ) -> ResponseT | _StreamT: [1267](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1267) opts = FinalRequestOptions.construct( [1268](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1268) method="post", [1269](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1269) url=path, (...) [1273](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1273) **options, [1274](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1274) ) -> [1275](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1275) return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) File c:\Notes\writer\.venv\lib\site-packages\writerai\_base_client.py:958, in SyncAPIClient.request(self, cast_to, options, remaining_retries, stream, stream_cls) [955](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:955) else: [956](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:956) retries_taken = 0 --> [958](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:958) return self._request( [959](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:959) cast_to=cast_to, [960](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:960) options=options, [961](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:961) stream=stream, [962](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:962) stream_cls=stream_cls, [963](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:963) retries_taken=retries_taken, [964](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:964) ) File c:\Notes\writer\.venv\lib\site-packages\writerai\_base_client.py:1061, in SyncAPIClient._request(self, cast_to, options, retries_taken, stream, stream_cls) [1058](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1058) err.response.read() [1060](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1060) log.debug("Re-raising status error") -> [1061](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1061) raise self._make_status_error_from_response(err.response) from None [1063](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1063) return self._process_response( [1064](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1064) cast_to=cast_to, [1065](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1065) options=options, (...) [1069](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1069) retries_taken=retries_taken, [1070](file:///C:/Notes/writer/.venv/lib/site-packages/writerai/_base_client.py:1070) ) BadRequestError: Error code: 400 - {'tpe': 'fail.input.generic', 'errors': [{'description': "filename doesn't exist", 'key': 'fail.input.generic', 'extras': None}], 'extras': None}
Also docs are inconsistent with SDK. the client.files.upload guidance on doc is missing required content_type https://dev.writer.com/api-guides/knowledge-graph
client.files.upload
content_type
The text was updated successfully, but these errors were encountered:
Unhandled exception
No branches or pull requests
(if you think this is solvable through the SDK alone, happy to submit a PR, in that instance any guidance would be awesome)
To reproduce:
Error message:
Also docs are inconsistent with SDK.
the
client.files.upload
guidance on doc is missing requiredcontent_type
https://dev.writer.com/api-guides/knowledge-graph
The text was updated successfully, but these errors were encountered: