-
Notifications
You must be signed in to change notification settings - Fork 172
Error trying to create basic item #51
Comments
According to #22 this is an item of type 1, to which you have to pass a list of uris. For a secure note, pass a type 2. You have to fill out the other object types too, e.g., for fields. |
Answer to original question: {
"card": null,
"favorite": false,
"fields": [],
"folderId": null,
"identity": null,
"login": null,
"name": "my_name",
"notes": "my_secure_note",
"organizationId": "some-guid",
"secureNote": "",
"type": 2
} Put into a file, Then run:
|
Closed ticket too early: With organization ID, without type: bw get template item | \
jq '.name = "Test Item" | .organizationId = "*********-****-****-****-******"' | \
bw encode | bw create item
With organization ID, with type: bw get template item | \
jq '.name = "Test Item" | .type = 2 | .organizationId = "*********-****-****-****-******"' | \
bw encode | bw create item
|
I created a wrapper with Python that can be added directly to function bwcreate() {
local python_code=$(cat - <<EOF
import argparse;import json;import secrets;import sys
parser = argparse.ArgumentParser(description='Create bitwarden item')
required = parser.add_argument_group('required named arguments')
required.add_argument('-n', '--name', required=True, help='name of item')
required.add_argument('-l', '--login', required=True)
parser.add_argument('-p', '--password', help='auto generate if empty')
parser.add_argument('-no', '--note')
if len(sys.argv)==1:
parser.print_help(sys.stderr)
sys.exit(1)
args = parser.parse_args()
if not args.password:
args.password = secrets.token_urlsafe(14)
login_data = {'username':args.login,'password':args.password}
data = {'organizationId':None,'folderId':None,'type':1,'name':args.name,'notes':args.note,'favorite':False,'fields':[],'login':None,'secureNote':None,'card':None,'identity':None}
data.update(login=login_data)
print(json.dumps(data))
EOF
)
json=$(python3 -c $python_code "$@")
if (( status != 0 )); then
return 1
fi
echo $json | bw encode | bw create item
} |
btw, "type" 2 at the root corresponds to "Item Types" table in reference. The template |
@jimsnab, the secure note type looks to be unused at the moment - it's an enum with only 1 value: export enum SecureNoteType {
Generic = 0,
} You may still have to specify it when you create the item though, I'm not sure. The other questions in this thread seem to have been discussed and resolved, and it's otherwise been inactive for some time. We use GitHub issues as a place to track bugs and other development related issues, not user support, so I'll close this. If anyone would like help using or configuring Bitwarden, please contact our Customer Success team here: https://bitwarden.com/contact. You can also search for an answer in our help documentation or get help from other Bitwarden users on our community forums. The issue here will be closed. |
Hi,
I'm trying to create a basic item via the CLI:
bw get template item | jq '.name = "dev_mariadb_master_pvc"' | bw encode | bw create item
But doing this, I get the error:
(node:25703) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'uris' of null at Function.toView (/snapshot/cli/build/bw.js:95146:17) at Function.toView (/snapshot/cli/build/bw.js:95232:49) at create_command_CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:102561:82) at Generator.next (<anonymous>) at create_command_awaiter (/snapshot/cli/build/bw.js:102511:71) at new Promise (<anonymous>) at create_command_awaiter (/snapshot/cli/build/bw.js:102507:12) at create_command_CreateCommand.createCipher (/snapshot/cli/build/bw.js:102560:16) at create_command_CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:102549:39) at Generator.next (<anonymous>) (node:25703) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:25703) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. root@util:~/devenv# bw get template item | jq '.name = "dev_mariadb_master_pvc"' | bw encode | bw create item (node:25773) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'uris' of null at Function.toView (/snapshot/cli/build/bw.js:95146:17) at Function.toView (/snapshot/cli/build/bw.js:95232:49) at create_command_CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:102561:82) at Generator.next (<anonymous>) at create_command_awaiter (/snapshot/cli/build/bw.js:102511:71) at new Promise (<anonymous>) at create_command_awaiter (/snapshot/cli/build/bw.js:102507:12) at create_command_CreateCommand.createCipher (/snapshot/cli/build/bw.js:102560:16) at create_command_CreateCommand.<anonymous> (/snapshot/cli/build/bw.js:102549:39) at Generator.next (<anonymous>) (node:25773) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:25773) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I can create a folder fine using your documentation example:
bw get template folder | jq '.name = "My Folder"' | bw encode | bw create folder
Can you help by providing working item creation code, for a secure note, please?
Regards,
Andy
The text was updated successfully, but these errors were encountered: