Create Document Entry with Notes field
I'm trying to create a "Document" type of 1Password Entry using the Python SDK for Secrets Automation. I know we can't upload files at the moment, but I want to create it as a placeholder (for the time being) and then direct the user to attach the file to the new entry manually. This entry would then automatically have the right tags given to it by my scripts etc.
At the moment, if I run the following:
from onepasswordconnectsdk.models import ItemVault, Field, Item item = Item( vault=ItemVault(id=vault_id), title="test", category="DOCUMENT", tags=["1password-connect"], fields=[Field(value="This is a test Item", purpose="NOTES")], ) client.create_item(vault_id, item)
it fails with the following:
Traceback (most recent call last): File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "c:\Users\johnn\.vscode\extensions\ms-python.python-2021.9.1230869389\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module> cli.main() File "c:\Users\johnn\.vscode\extensions\ms-python.python-2021.9.1230869389\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main run() File "c:\Users\johnn\.vscode\extensions\ms-python.python-2021.9.1230869389\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file runpy.run_path(target_as_str, run_name=compat.force_str("__main__")) File "C:\Python39\lib\runpy.py", line 268, in run_path return _run_module_code(code, init_globals, run_name, File "C:\Python39\lib\runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "C:\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "c:\Work\scripts\onepassword_secrets\onepassword_secrets\onepassword.py", line 417, in <module> main() File "c:\Work\scripts\onepassword_secrets\onepassword_secrets\onepassword.py", line 404, in main client.create_item(vault_id, item) File "c:\Users\johnn\AppData\Local\pypoetry\Cache\virtualenvs\onepassword-secrets-py0LK9l0-py3.9\lib\site-packages\onepasswordconnectsdk\client.py", line 177, in create_item raise FailedToRetrieveItemException( onepasswordconnectsdk.client.FailedToRetrieveItemException: Unable to post item. Received 400 for /v1/vaults/tbouu4flygrypkkzjzduo5m7gq/items with message: Validation: (validateVaultItem failed to Validate), Couldn't validate the item: "[ItemValidator] has found 1 errors, 0 warnings: \nErrors:{1. Field of unexpected type \"\" at \"item.details.documentAttributes\". Requires one of [\"object\"]}"
Hoever, if I were to change the category to SECURE_NOTE
for example, it runs happily:
from onepasswordconnectsdk.models import ItemVault, Field, Item item = Item( vault=ItemVault(id=vault_id), title="test", category="SECURE_NOTE", tags=["1password-connect"], fields=[Field(value="This is a test Item", purpose="NOTES")], ) client.create_item(vault_id, item)
When I look at an existing "Document", I see it has a NOTES
field, so I'm wondering, is it just not possible to create a DOCUMENT
type of entry with no attachement, but we obviously can't add an attachment at the moment, so it's not possible to create this type of entry at all for the time being? Or is something else going wrong?
1Password Version: !Password Connect 1.3.1
Extension Version: Not Provided
OS Version: Not Provided
Comments
-
You're right that uploading files in Connect are not yet supported. And at the same time, having documents without attached files is also not supported, so creating 'partial' documents is not possible either. We are working on better file workflows in Connect and its SDKs.
What you can do now is create normal items in Connect, and then using the 1Password 8 betas, attach your files as fields. Another benefit there is that you can add multiple files to the same item, where as documents only correspond to a single file.
The error message you posted could be more clear on the fact that documents are not supported, I will report that to the team.
0